#auth #development #laravel #php
Laravel makes hard stuff really easy to do.
Imagine the case where you want to be able to login as a different user (a scenario which happens a lot during development). Instead of entering the credentials over and over again, you can do something like this:
1if (app()->environment('local') {
2 Auth::logout();
3
4 $user = User::find(1); // Or a different query to get the correct user
5
6 Auth::login($user);
7}
Just be aware that this can be a security issue, hence the check to make this work only in the local environment.
Never, ever, allow stuff like this on production.
If this post was enjoyable or useful for you, please share it! If you have comments, questions, or feedback, you can email my personal email. To get new posts, subscribe use the RSS feed.