Skip to content

Instantly share code, notes, and snippets.

@yavgel85
Last active March 26, 2021 08:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yavgel85/1f8d2b6407d36a67487abc175d9ed1d3 to your computer and use it in GitHub Desktop.
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
<?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