Last active
March 26, 2021 08:16
-
-
Save yavgel85/1f8d2b6407d36a67487abc175d9ed1d3 to your computer and use it in GitHub Desktop.
Working locally and don't want to log in manually every time when working with randomized database seeds? #laravel #auth
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// routes/web.php | |
Route::get('auto-login', function() { | |
// Only available in local environment | |
abort_unless(app()->environment('local'), 403); | |
// Login with first user from DB seeds | |
auth()->login(User::first()); | |
// Redirect to homepage | |
return redirect()->to('/'); | |
})->name('dev-login'); | |
// login.blade.php | |
@env('local') | |
<a href="{{ route('dev-login') }}">Developer Account</a> | |
@endenv | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment