findByEmail() public static method

Looks up a user by their email address.
public static findByEmail ( $email ) : self
return self
コード例 #1
0
 /**
  * Trigger the password reset email
  */
 public function onRestorePassword()
 {
     $rules = ['email' => 'required|email|between:6,255'];
     $validation = Validator::make(post(), $rules);
     if ($validation->fails()) {
         throw new ValidationException($validation);
     }
     if (!($user = UserModel::findByEmail(post('email')))) {
         throw new ApplicationException(trans('rainlab.user::lang.account.invalid_user'));
     }
     $code = implode('!', [$user->id, $user->getResetPasswordCode()]);
     $link = $this->controller->currentPageUrl([$this->property('paramCode') => $code]);
     $data = ['name' => $user->name, 'link' => $link, 'code' => $code];
     Mail::send('rainlab.user::mail.restore', $data, function ($message) use($user) {
         $message->to($user->email, $user->full_name);
     });
 }