예제 #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);
 }