where("user_id", "=", $this->id) ->where("primary", "=", 1) ->where("status", "=", "valide") ->first(); if(is_null($mail)) { return null; } return $mail->mail; } public function createMailResetToken() { $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $randstring = ''; for ($i = 0; $i < 20; $i++) { $randstring .= $characters[rand(0, strlen($characters)-1)]; } $this->password_recovery_code = $randstring; } }