/** * Handle the command. * * @param UserRepositoryInterface $users * @return bool */ public function handle(UserRepositoryInterface $users) { if (!($user = $users->findByActivationCode($this->code))) { return false; } if ($this->user->getId() !== $user->getId()) { return false; } $this->user->activated = true; $this->user->activation_code = null; $users->save($this->user); return true; }
/** * Handle the command. * * @param UserRepositoryInterface $users * @return bool */ public function handle(UserRepositoryInterface $users) { $user = $users->findByResetCode($this->code); if (!$user) { return false; } if ($user->getId() !== $this->user->getId()) { return false; } $this->user->setAttribute('reset_code', null); $this->user->setAttribute('password', $this->password); $users->save($this->user); return true; }
/** * Limit to preferences belonging to the provided user. * * @param Builder $query * @param UserInterface $user */ public function scopeBelongingToUser(Builder $query, UserInterface $user) { $query->where('user_id', $user->getId()); }