I want to redirect the admin user to dasheboard but the Admin-login page always get refreshed, I set up admins tables and ran the migrations and I added one admin with tinkle command
AdminLoginController.php
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use App\Admin;
class AdminLoginController extends Controller
{
public function login(Request $request){
$this->validate($request,[
'email'=>'required|email',
'password'=>'required|min:6'
]);
if ((Auth::guard('admin')->attempt(['email' => $request->email, 'password' => $request->password])) ){
return redirect()->intended('Admin.dasheboard');
}
return redirect()->back();
}
public function show(){
return view(' Admin.admin-login');
}
}
My routes:
Route::prefix('admin')->group(function(){
Route::get('/', 'Admin\AdminController@show');
Route::get('/login', 'Admin\AdminLoginController@show');
Route::post('/login', 'Admin\AdminLoginController@login');
});
Auth.php
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\User::class,
],
'admins' => [
'driver' => 'eloquent',
'model' => App\Admin::class,
],
'users' => [
'driver' => 'database',
'table' => 'users',
],
'admins' => [
'driver' => 'database',
'table' => 'admins',
],
],
For the blade page it has:
<form action="/admin/login" method="post">
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire