Ad

Force Laravel To Use MySQL For Authentication When MongoDB Is Set As Default

- 1 answer

I thought by having the follwing line in User.php was enough. Where else do I need to modify my DB connection?

protected $connection = 'mysql';

However, when attempting to reset my password, it's throwing an error. I see it's trying to communicate with my MongoDB DB, which is my default DB.

strtotime() expects parameter 1 to be string, array given
in /var/www/html/ocd3/vendor/laravel/framework/src/Illuminate/Auth/Passwords/DatabaseTokenRepository.php line 126 at HandleExceptions->handleError('2', 
'strtotime() expects parameter 1 to be string, array given',
'/var/www/html/ocd3/vendor/laravel/framework/src/Illuminate/Auth/Passwords/DatabaseTokenRepository.php', '126', array('token' => array('_id' => object(MongoId), '
Ad

Answer

Someone faced this same problem here: https://laracasts.com/discuss/channels/laravel/designate-connection-for-password-resets-table-other-than-default

Basically: password_resets table differs from users table, so I guess you must set the desired connection in the config/auth.php file:

'passwords' => [
    'users' => [
        'provider' => 'users',
        'email' => 'auth.emails.password',
        'table' => 'CUSTOM_CONNECTION.password_resets',
        'expire' => 60,
    ],
],
Ad
source: stackoverflow.com
Ad