3 namespace BookStack\Auth\Permissions;
5 use BookStack\Auth\Role;
7 use Illuminate\Database\Eloquent\Relations\BelongsToMany;
11 * @property string $name
12 * @property string $display_name
14 class RolePermission extends Model
17 * The roles that belong to the permission.
19 public function roles(): BelongsToMany
21 return $this->belongsToMany(Role::class, 'permission_role', 'permission_id', 'role_id');
25 * Get the permission object by name.
27 public static function getByName(string $name): ?RolePermission
29 return static::where('name', '=', $name)->first();