/**
* Perform password reset
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function forgot(Request $request)
{
try {
//receive data
$data = $this->handlePayloadRequest(
$request,
$this->getForgotRules(),
$this->getForgotMessages()
);
} catch (\Throwable $th) {
return $this->handleError(
$th->getMessage(),
Response::HTTP_METHOD_NOT_ALLOWED
);
}
try {
//find user
$user = User::where('email', $data['email'])->firstOrFail();
} catch (\Throwable $th) {
return $this->handleError(
Config::get('constants.messages.errors.users.unauthorized'),
Response::HTTP_NOT_FOUND
);
}
//Enable the password change request with a code
// of verification and with the current date to expire in up to 1h
//after request.
$dt_order = now();
$code = Str::random(10);
$user->forgot_dt = $dt_order;
$user->forgot_code = Hash::make($code);
$user->save();
//create request
$order = new OrderSendMail('forgot', [
'user' => $user,
'date' => $dt_order,
'code' => $code
]);
try {
//Send by email
Mail::to($user->email)->send($order);
} catch (\Throwable $th) {
return $this->handleError(
Config::get('constants.messages.errors.email.unsent'),
Response::HTTP_NOT_FOUND
);
}
Log::info($code);
return $this->handleSuccess([
'message' => Config::get('constants.messages.forgot.sended')
]);
}
#Reset password Laravel
5 messages · Page 1 of 1 (latest)
app\Mail\OrderSendMail.php
class OrderSendMail extends Mailable
{
use Queueable, SerializesModels;
private $template;
private $data;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct(string $template = 'default', $data = [])
{
$this->template = "emails.$template";
$this->data = $data;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->from(Config::get('constants.email.from'), Config::get('constants.email.name'))
->view($this->template, $this->data);
}
}```
resources\views\emails\forgot.blade.php
```php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="x-apple-disable-message-reformatting">
<meta content="telephone=no" name="format-detection">
<title></title>
</head>
<div>
<span style="color:#eaeaea;display:none!important;font-size:1px;line-height:1px;max-height:0;max-width:0;overflow:hidden;visibility:hidden;" class="yiv9626108834preheader"> </span>
<table id="yiv9626108834background" role="presentation" cellpadding="0" cellspacing="0" border="0" align="center" width="100%" bgcolor="#eaeaea">
<tr>
<td>
//*****SEND EMAIL RESET HERE
</td>
</tr>
</table>
</div>
</html>```
How do I send the link in my forgot.blade.php file?
Why are you doing all this when Laravel already has password resets out of the box?
Because I'm working on a code that has been started. And the old developer did it this way. I'm not sure how to pass the reset link with the token