1

I'm currently building an application which has different types of users. I want to create these user types and be able to authenticate them.

I copied the User class and made

class Owner extends Authenticatable
{
    protected $fillable = [ 'name', 'email', 'pass'];
}

then in my controller

// Register Owner
$owner = Owner::create([
   'name' => request('name'), 
   'email' => request('email'), 
   'password' => bcrypt(request('password'))
]);

// Sign In
auth()->login($owner);      

added the following to config/auth.php

'providers' => [
    'users' => [
        'driver' => 'eloquent',
        'model' => App\User::class,
    ],
    'instructors' => [
        'driver' => 'eloquent',
        'model' => App\Instructor::class,
    ],
    'owners' => [
        'driver' => 'eloquent',
        'model' => App\Owner::class,
    ],
],

But this does not authenticate my custom class. Is there something else I should be doing?

Thanks for your help!

Jacob

Gum
  • 21
  • 1
  • 5

1 Answers1

0

You need to add your models to the /config/auth.php as provider.

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

        // 'users' => [
        //     'driver' => 'database',
        //     'table' => 'users',
        // ],
    ],
  • Hi Anton, thanks for your answer. I added my models to /config/auth.php but still not working – Gum Jan 30 '17 at 13:37
  • did you add guards as well? Maybe this will help: http://stackoverflow.com/questions/34614753/can-anyone-explain-laravel-5-2-multi-auth-with-example – Anton Grigorov Jan 30 '17 at 13:43