Exemplo n.º 1
0
 /**
  * Get generated users in count
  *
  * @param $count
  * @return mixed
  */
 public function getGeneratedUsers(User $user, $count = 5)
 {
     return $user->generatedUsers()->where('is_customer', true)->take($count)->orderBy('created_at', 'DESC')->get();
 }
Exemplo n.º 2
0
 /**
  * Remove all user groups
  *
  * @param $user
  * @return void
  */
 public function removeUserGroups(User $user)
 {
     $groups = $user->getGroups();
     foreach ($groups as $group) {
         $user->removeGroup($group);
     }
 }
Exemplo n.º 3
0
 public function updateMe(User $user, array $input, UpdateListenerInterface $listener)
 {
     $this->profileValidator->setCurrentIdFor('email', $user->id);
     if (!($valid = $this->profileValidator->isValid($input))) {
         return $listener->onUpdateFail($this->profileValidator->getMessages());
     }
     if (!empty($input['password'])) {
         if (!$user->checkPassword($input['old_password'])) {
             return $listener->onUpdateFail([Lang::get("messages.old_password_incorrect")]);
         }
     }
     unset($input['old_password']);
     unset($input['password_confirmation']);
     try {
         $this->userRepo->update($user->id, $input);
         return $listener->onUpdateSuccess(Lang::get("messages.operation_success"));
     } catch (NotFoundException $e) {
         return $listener->onUpdateNotFound();
     } catch (RepositoryException $e) {
         return $listener->onUpdateFail([Lang::get("messages.database_error")]);
     }
 }
Exemplo n.º 4
0
 public function getSearchableCreatorOrders(User $creator, $int)
 {
     return $creator->orders()->with('state', 'customer', 'creator')->makeSearchable()->makeSortable()->paginate($int);
 }
Exemplo n.º 5
0
 /**
  * @author bigsinoos <*****@*****.**>
  * Reminding leads of the user
  *
  * @param User $user
  * @param int $int
  * @return mixed
  */
 public function getRemindableLeads(User $user, $int = 50)
 {
     $todayStart = Carbon::createFromTimestamp(time())->startOfDay()->toDateTimeString();
     return $user->createdLeads()->where('remind_at', '>', $todayStart)->with('tags', 'phones')->orWhere(function ($q) use($user) {
         $q->where('updated_at', '<', 'remind_at')->where('creator_id', $user->id)->whereNotNull('remind_at');
     })->orderBy('remind_at', 'ASC')->take($int)->get();
 }