What I have done so far.
I am trying to authenticate users and admin form user table and admin table respectively.
I am using the User model as provided by laravel out of the box and created exactly same for Admin.
I have added a guard key and provider key into auth.php
Guards
'guards' => [
'user' =>[
'driver' => 'session',
'provider' => 'user',
],
'admin' => [
'driver' => 'session',
'provider' => 'admin',
],
],
Providers
'providers' => [
'user' => [
'driver' => 'eloquent',
'model' => App\User::class,
],
'admin' => [
'driver' => 'eloquent',
'model' => App\Admin::class,
]
],
Routes
Route::group(['middleware' => ['web']], function () {
//Login Routes...
Route::get('/admin/login','AdminAuth\AuthController@showLoginForm');
Route::post('/admin/login','AdminAuth\AuthController@login');
Route::get('/admin/logout','AdminAuth\AuthController@logout');
// Registration Routes...
Route::get('admin/register', 'AdminAuth\AuthController@showRegistrationForm');
Route::post('admin/register', 'AdminAuth\AuthController@register');
Route::get('/admin', 'AdminController@index');
});
I have created a directory called AuthAdmin where Laravel's default AuthController.php and PasswordController.php files are present. (Namespace Modified accordingly)
First of all in Laravel's docs mentioned that how to specify custom guard while authenticating like this which isn't working.
There's another method mentioned in laravel's docs to use a guard which is not working too.
It would be very helpful if someone could resolve the issues and and correct me if I am wrong.
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1Sxhek3
via IFTTT
Aucun commentaire:
Enregistrer un commentaire