Cartalyst\Sentinel\Users\UserRepositoryInterface::validForUpdate PHP Method

validForUpdate() public method

Validate if the given user is valid for updating.
public validForUpdate ( Cartalyst\Sentinel\Users\UserInterface | integer $user, array $credentials ) : boolean
$user Cartalyst\Sentinel\Users\UserInterface | integer
$credentials array
return boolean
    public function validForUpdate($user, array $credentials);

Usage Example

 /**
  * {@inheritDoc}
  */
 public function complete(UserInterface $user, $code, $password)
 {
     $expires = $this->expires();
     $reminder = $this->createModel()->newQuery()->where('user_id', $user->getUserId())->where('code', $code)->where('completed', false)->where('created_at', '>', $expires)->first();
     if ($reminder === null) {
         return false;
     }
     $credentials = compact('password');
     $valid = $this->users->validForUpdate($user, $credentials);
     if ($valid === false) {
         return false;
     }
     $this->users->update($user, $credentials);
     $reminder->fill(['completed' => true, 'completed_at' => Carbon::now()]);
     $reminder->save();
     return true;
 }