попробуйте это:
AdminForgotPasswordController. php
class AdminForgotPasswordController extends Controller
{
use SendsPasswordResetEmails;
protected function broker(){
return Password::broker('admins');
}
public function sendResetLinkEmail(Request $request){
$input = $request->all();
$rules = array(
'email' => "required",
);
$validator = Validator::make($input, $rules);
if ($validator->fails()) {
$arr = array("status" => 400, "message" => $validator->errors()->first());
} else {
// check if user already exists
$users = Admins::all();
if(!$users->isEmpty()){
foreach($users as $user){
if($user->email == $request['email']){
break;
}
$user = false;
}
}else{
$user = false;
}
if(!$user){
$arr = array("status" => 400, "message" => "That user doesn't exist");
return \Response::json($arr);
}
// create reset pass token
$token = Password::getRepository()->create($user);
$user->notify(new SendResetPasswordAdmin($token,$user->email));
$arr = array("status" => 200, "message" => "Email to reset password sent");
return \Response::json($arr);
}
}
}
И вам необходимо создать SendResetPasswordAdmin в приложении / уведомлениях, для которых эта команда php ремесленник делает: уведомление SendResetPasswordAdmins
class SendResetPasswordAdmins extends Notification
{
use Queueable;
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct($token,$email)
{
$this->token = $token;
$this->email = $email;
}
public function via($notifiable)
{
return ['mail'];
}
public function toMail($notifiable)
{
return (new MailMessage)
->line(Yourmessage)
->action('Message2', route('admins.password.reset', ['token' =>$this->token, 'email' => $this->email]))
->line(FooterMessage);
}
Маршрут:
Route::get('admins/password/reset/{token}/{email}',
'ResetPasswordAdmins@showResetForm')->name('admins.password.reset');
А это:
class ResetPasswordAdmins extends Controller
{
public function showResetForm($token,$email){
return view(yourView)->with(['token' => $token, 'email'
=> $email]);
}
public function updatePass(Request $request){
//Here your logic and validator
}