Reset password laravel 5.5

-1

I created my own model and modified the provider to use my model called Admin in config & auth.php

'providers' => [
        'users' => [
            'driver' => 'eloquent',
            'model' => App\Admin::class,
        ],

and my model will add the following:

<?php

namespace App;

use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Contracts\Auth\CanResetPassword;

class Admin extends Authenticatable
{

    public function sendPasswordResetNotification($token)
    {
        $this->notify(new MyResetPassword($token));
    }  
}

and now I have to create something like that? I do not understand much about the documentation, this is the one I'm seeing link

The point is that in my login I have a link that says to reset your password so when I click I want you to send me the link to reset the password

    
asked by Naoto Amari 05.03.2018 в 13:19
source

1 answer

0

I think you're a little lost. As I understand the only thing you changed was the model, users are not authenticated but administrators. Beyond that you could even have the 2 options running simultaneously. It is a complicated subject to explain but it is not at all complicated in itself.
 1- You need to add the trait Notifiable to your model.

<?php

namespace App;

use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;

class Admin extends Authenticatable
{
    use Notifiable;

}

2- You have to create a notification, ONLY in case you want to change the notification by default and in this case if, you would need to add the method.

<?php

namespace App;

use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use App\Notifications\MyResetPassword; 
// php artisan make:notification MyResetPassword

class Admin extends Authenticatable
{
    use Notifiable;
    public function sendPasswordResetNotification($token)
    {
        $this->notify(new MyResetPassword($token));
    }  
}

3- Then if the case is that you want to have a double authentication, I mean with users and with admins there is a little complicated because you have to do a few things more.
 to. Add a new guard in config / auth
 b. Add a new provider in config / auth
 c. Add a new password in config / auth
 ....
 I leave you a tutorial that I found Multiple Authentication in Laravel 5.4

    
answered by 10.03.2018 в 10:34