/**
  * @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));
 }
Exemple #2
0
 /**
  * @param $where
  *
  * @dataProvider whereOkProvider
  */
 public function testWherePaginateOk($where)
 {
     $this->assertInstanceOf(LengthAwarePaginator::class, $this->repository->where($where, true));
 }
 /**
  * Permission constructor.
  */
 public function __construct($className)
 {
     parent::__construct($className);
 }
Exemple #4
0
 /**
  * Permission constructor.
  */
 public function __construct()
 {
     parent::__construct(\App\Permission::class);
 }