1class User extends Authenticatable
2{
3 // ...
4
5 public function isAuthorized($object, $operation)
6 {
7 return Db::table('role_permissions')
8 ->where('object', $object)
9 ->where('operation', $operation)
10 ->join('user_roles', 'user_roles.role_id', '=', 'role_permissions.role_id')
11 ->where('user_roles.user_id', $this->id)
12 ->exists();
13 }
14}
15