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