代码拉取完成,页面将自动刷新
<?php
/**
* Created by PhpStorm.
* User: sdf_sky
* Date: 16/6/20
* Time: 下午6:14
*/
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Role extends Model
{
protected $table = 'roles';
protected $fillable = ['id', 'name','description','sort','slug'];
public function permissions()
{
return $this->belongsToMany('App\Models\Permission');
}
/**
* Determine if the role has the given permission.
*
* @param mixed $permission
* @return boolean
*/
public function inRole($permission)
{
if (is_string($permission)) {
return $this->permissions->contains('name', $permission);
}
return !! $permission->intersect($this->permissions)->count();
}
/**
* @param $permission
* @return bool
*/
public function attachPermission($permission)
{
return (!$this->permissions()->get()->contains($permission)) ? $this->permissions()->attach($permission) : true;
}
/**
* @param $permission
* @return mixed
*/
public function detachPermission($permission)
{
return $this->permissions()->detach($permission);
}
/**
* Detach all permissions.
*
* @return int
*/
public function detachAllPermissions()
{
return $this->permissions()->detach();
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。