]> BookStack Code Mirror - bookstack/blob - app/Auth/Permissions/RolePermission.php
Added more complexity in an attempt to make ldap host failover fit
[bookstack] / app / Auth / Permissions / RolePermission.php
1 <?php
2
3 namespace BookStack\Auth\Permissions;
4
5 use BookStack\Auth\Role;
6 use BookStack\Model;
7 use Illuminate\Database\Eloquent\Relations\BelongsToMany;
8
9 /**
10  * @property int $id
11  */
12 class RolePermission extends Model
13 {
14     /**
15      * The roles that belong to the permission.
16      */
17     public function roles(): BelongsToMany
18     {
19         return $this->belongsToMany(Role::class, 'permission_role', 'permission_id', 'role_id');
20     }
21
22     /**
23      * Get the permission object by name.
24      */
25     public static function getByName(string $name): ?RolePermission
26     {
27         return static::where('name', '=', $name)->first();
28     }
29 }