i have created admin login system but on auth::attempt its always returning false here is my code
$credentials= ['email' => $request->get('email'), 'password'=>$request->get('password')];
if (Auth::guard('admin')->attempt($credentials)) {
return redirect()->intended(route('admin.dashboard'));
}
in Admin model
<?php
namespace App\Models;
use Illuminate\Foundation\Auth\User as Authenticatable;
class Admin extends Authenticatable
{
protected $guard = 'admin';
protected $primary_key = 'admin_id';
protected $table = 'admins';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'admin_firstname', 'admin_lastname', 'email', 'admin_username', 'admin_phone', 'admin_picture', 'admin_gender', 'password',
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
}
in auth.php
'guards' => [
'admin' => [
'driver' => 'session',
'provider' => 'admins',
],
auth::attempt is failing dont know why its not working
its logging but problem is found in admin middleware $this->middleware('auth:admin');
my auth.php
'guards' => [
'admin' => [
'driver' => 'session',
'provider' => 'admins',
],
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'api' => [
'driver' => 'token',
'provider' => 'users',
],
],
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\Models\User::class,
],
'admins' => [
'driver' => 'eloquent',
'model' => App\Models\Admin::class,
],
],
degault guard is set as web but in dashboard controller i am using auth:admin please check
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire