/**
* {@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;
}