0
votes

I have created a custom login (not using default laravel auth) for some business design forced reason that i need to adjust. Is there a way that all Auth procedures (checking session, login, logout, etc..) will look into another table? My google research points me to config/auth.php to change the table value there but when I opened it, there is no 'table' value in the config so I added it manually

'table' => 'user_admin',

..unfortunately, nothing has changed. Session checking still checks in users table.

Thanks for any inputs.

1
if you have user_admin table just add this code to your User model protected $table = 'user_admin'; as web guard uses users as provider and users provider have User as model classprogrammingArrow

1 Answers

0
votes

go to

config/auth.php

    /*
|--------------------------------------------------------------------------
| User Providers
|--------------------------------------------------------------------------
|
| All authentication drivers have a user provider. This defines how the
| users are actually retrieved out of your database or other storage
| mechanisms used by this application to persist your user's data.
|
| If you have multiple user tables or models you may configure multiple
| sources which represent each model / table. These sources may then
| be assigned to any extra authentication guards you have defined.
|
| Supported: "database", "eloquent"
|
*/

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

    // 'users' => [
    //     'driver' => 'database',
    //     'table' => 'users',
    // ],
],

You'll maybe also need to modify the validator method in the RegisterController

You can change the table name in the migration file and then change the table name variable in the User.php model.

Example:

   class MyTable extends Model
    {
        /**
         * The table associated with the model.
         *
         * @var string
         */
        protected $table = 'my_table';
    }

https://laravel.com/docs/5.4/eloquent#eloquent-model-conventions