2018-09-25 07:30:50 -04:00
|
|
|
<?php namespace BookStack\Auth\Permissions;
|
|
|
|
|
|
|
|
use BookStack\Auth\Role;
|
|
|
|
use BookStack\Model;
|
2015-08-29 10:03:42 -04:00
|
|
|
|
2016-05-01 16:20:50 -04:00
|
|
|
class RolePermission extends Model
|
2015-08-29 10:03:42 -04:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* The roles that belong to the permission.
|
|
|
|
*/
|
|
|
|
public function roles()
|
|
|
|
{
|
2018-01-28 11:58:52 -05:00
|
|
|
return $this->belongsToMany(Role::class, 'permission_role', 'permission_id', 'role_id');
|
2015-08-29 10:03:42 -04:00
|
|
|
}
|
2016-02-27 14:24:42 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the permission object by name.
|
2016-04-24 11:54:20 -04:00
|
|
|
* @param $name
|
2016-02-27 14:24:42 -05:00
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public static function getByName($name)
|
|
|
|
{
|
|
|
|
return static::where('name', '=', $name)->first();
|
|
|
|
}
|
2015-08-29 10:03:42 -04:00
|
|
|
}
|