@tomchabo In this case, here is your solution, you can add the following code in the boot method of AppServiceProvider for example :
if (config('app.env') === 'local') {
$user = \App\Models\User::newModelInstance([
'name' => 'OtherTestUser',
'email' => '[email protected]',
'password' => Hash::make('secretpass'),
]);
Auth::login($user);
}
Please note the usage of firstOrNew, this would create a User object without persisting it in the database. Besides, the code is wrapped inside an if to make sure it is run only in the local environment: we don't want people to login like this in production.
FInally, I suggested to put the code in the boot method of AppServiceProvider since it is run in every request. You can put the code elsewhere if you prefer.