lundi 5 février 2018

Laravel: Change guard in LoginController

My default guard is web. I have created a second guard called normal. Here are the settings of my config/auth,php file

  'guards' => [
        'web' => [
            'driver' => 'session',
            'provider' => 'users',
        ],

        'api' => [
            'driver' => 'token',
            'provider' => 'users',
        ],

        'normal' => [
          'driver' => 'session',
          'provider' => 'people',
        ]
    ],

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

        'people' =>[
            'driver' => 'eloquent',
            'model' => App\User::class,
        ]
    ],

Further I have a controller at app/Http/Controller/Auth/LoginController.php

use Illuminate\Foundation\Auth\AuthenticatesUsers;

class LoginController extends Controller
{

    use AuthenticatesUsers;

    protected function guard()
    {
        return \Auth::guard('normal');
    }

    public function test()
    {
      dd("hi");
    }

If I try to call this LoginController via Route::get('/test', 'Auth\LoginController@test'); but I get an error that he tries to something with App\VoyagerUser. But why is he working with that class? He should be using normal guard which is associated with the model App\User.

Can anyone help me out? Here is the stated error: enter image description here



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire