BookStack/app/Auth/Permissions/RolePermission.php

33 lines
591 B
PHP
Raw Normal View History

2021-06-26 23:23:15 +08:00
<?php
namespace BookStack\Auth\Permissions;
use BookStack\Auth\Role;
use BookStack\Model;
2015-08-29 22:03:42 +08:00
/**
* @property int $id
*/
class RolePermission extends Model
2015-08-29 22:03:42 +08:00
{
/**
* The roles that belong to the permission.
*/
public function roles()
{
return $this->belongsToMany(Role::class, 'permission_role', 'permission_id', 'role_id');
2015-08-29 22:03:42 +08:00
}
/**
* Get the permission object by name.
2021-06-26 23:23:15 +08:00
*
* @param $name
2021-06-26 23:23:15 +08:00
*
* @return mixed
*/
public static function getByName($name)
{
return static::where('name', '=', $name)->first();
}
2015-08-29 22:03:42 +08:00
}