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