/**
  * @param array $relations
  * @return array
  */
 private function getRelations(array $relations = [])
 {
     $with = is_array(Input::get('with')) ? Input::get('with') : $this->inputService->decode('with');
     if (count($relations) > 0) {
         $with = $relations;
     }
     $result = [];
     $relations = $this->repository->relations();
     foreach ($with as $key => $value) {
         if (in_array($key, $relations) || in_array($value, $relations)) {
             $result[$key] = $value;
         }
     }
     return $result;
 }
Пример #2
0
 /**
  * @param App $app
  * @param Collection $collection
  * @throws \App\Repositories\Exceptions\RepositoryException
  */
 public function __construct(App $app, Collection $collection, DailySalesRepository $dailysales, Purchase $purchase, PurchaseRepo $purchaserepo)
 {
     parent::__construct($app, $collection);
     $this->ds = $dailysales;
     $this->purchase = $purchase;
     $this->purchase2 = $purchaserepo;
 }
Пример #3
0
 public function save($id, $data)
 {
     $role = parent::save($id, $data);
     //Assing user roles
     $permissions = strlen($data['permissions']) ? explode(",", $data['permissions']) : [];
     $permissions = explode(',', trim($data['permissions']));
     if (count($permissions) > 0) {
         $role->permissions()->sync($permissions);
     }
     return $role;
 }
Пример #4
0
 public function save($id, $data)
 {
     if (isset($data['password'])) {
         $data['password'] = bcrypt($data['password']);
     }
     $user = parent::save($id, $data);
     //Assing user roles
     if (count($data['roles']) > 0) {
         $user->roles()->sync($data['roles']);
     }
     return $user;
 }
Пример #5
0
 /**
  * CtgRepository constructor.
  * @param Ctg  $ctg
  * @param Item $item
  */
 public function __construct(Ctg $ctg, Item $item)
 {
     parent::__construct();
     $this->ctg = $ctg;
     $this->item = $item;
 }
 /**
  * @param $input
  * @return mixed
  * @throws GeneralException
  */
 public function changePassword($input)
 {
     $user = parent::find(access()->id());
     if (Hash::check($input['old_password'], $user->password)) {
         $user->password = bcrypt($input['password']);
         return parent::save($user);
     }
     throw new GeneralException(trans('exceptions.frontend.auth.password.change_mismatch'));
 }
 /**
  * @param Model $user
  * @param $status
  * @return bool
  * @throws GeneralException
  */
 public function mark(Model $user, $status)
 {
     if (access()->id() == $user->id && $status == 0) {
         throw new GeneralException(trans('exceptions.backend.access.users.cant_deactivate_self'));
     }
     $user->status = $status;
     switch ($status) {
         case 0:
             event(new UserDeactivated($user));
             break;
         case 1:
             event(new UserReactivated($user));
             break;
     }
     if (parent::save($user)) {
         return true;
     }
     throw new GeneralException(trans('exceptions.backend.access.users.mark_error'));
 }
 /**
  * @param  Model $role
  * @throws GeneralException
  * @return bool
  */
 public function delete(Model $role)
 {
     //Would be stupid to delete the administrator role
     if ($role->id == 1) {
         //id is 1 because of the seeder
         throw new GeneralException(trans('exceptions.backend.access.roles.cant_delete_admin'));
     }
     //Don't delete the role is there are users associated
     if ($role->users()->count() > 0) {
         throw new GeneralException(trans('exceptions.backend.access.roles.has_users'));
     }
     DB::transaction(function () use($role) {
         //Detach all associated roles
         $role->permissions()->sync([]);
         if (parent::delete($role)) {
             event(new RoleDeleted($role));
             return true;
         }
         throw new GeneralException(trans('exceptions.backend.access.roles.delete_error'));
     });
 }
 /**
  * EmployeeRepository constructor.
  */
 public function __construct()
 {
     parent::__construct();
 }
 public function __construct(Provider $user)
 {
     parent::__construct($user);
 }
Пример #11
0
 public function __construct(Post $model)
 {
     parent::__construct($model);
 }
Пример #12
0
 /**
  * @param App $app
  * @param Collection $collection
  * @throws \App\Repositories\Exceptions\RepositoryException
  */
 public function __construct(App $app, Collection $collection, DailySalesRepository $dailysales)
 {
     parent::__construct($app, $collection);
     $this->ds = $dailysales;
 }
 public function __construct(Currency $model)
 {
     parent::__construct();
     $this->model = $model;
     $this->model->setPerPage($this->perPage);
 }
Пример #14
0
 public function __construct(App $app, Collection $collection, ByBranch $byBranch)
 {
     parent::__construct($app, $collection);
     $this->pushFilters($byBranch);
 }
Пример #15
0
 public function store(array $attributes = [])
 {
     $user = parent::store($attributes);
     auth()->login($user);
     return $user;
 }