/** * @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; }
/** * @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; }
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; }
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; }
/** * 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); }
public function __construct(Post $model) { parent::__construct($model); }
/** * @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); }
public function __construct(App $app, Collection $collection, ByBranch $byBranch) { parent::__construct($app, $collection); $this->pushFilters($byBranch); }
public function store(array $attributes = []) { $user = parent::store($attributes); auth()->login($user); return $user; }