示例#1
0
 /**
  * @author LAHAXE Arnaud
  *
  *  Add a criteria on repository if the user is not admin and
  *         the model is implementing UserRestrictionInterface
  *
  * @return bool
  */
 protected function addUserCriteria()
 {
     $model = $this->repository->getModel();
     if (!$model instanceof UserRestrictionInterface) {
         return true;
     }
     /** @var \App\User $user */
     $user = \Auth::user();
     // no current user and no user given, no access
     if (is_null($user)) {
         return false;
     }
     if ($user->isSuperAdmin()) {
         return true;
     }
     $this->repository->addCriteria(new User($user));
 }
示例#2
0
 /**
  * @param $where
  *
  * @dataProvider whereOkProvider
  */
 public function testWherePaginateOk($where)
 {
     $this->assertInstanceOf(LengthAwarePaginator::class, $this->repository->where($where, true));
 }
示例#3
0
 /**
  * Permission constructor.
  */
 public function __construct($className)
 {
     parent::__construct($className);
 }
示例#4
0
 /**
  * Permission constructor.
  */
 public function __construct()
 {
     parent::__construct(\App\Permission::class);
 }