How to Change the Redirect Route after Login in Laravel Spark
The past several days I spent some time searching Stack Overflow and Google for the answer to this question, so I thought you might appreciate it if I shared the answer here.
If you want to redirect users to a different route after login in Laravel Spark, I would not recommend trying to do it like you would with any other laravel app.
If you built a new Spark app with "spark new", you wont even have the login controller in your Http folder, and if you try changing your login controller in a Laravel app that had Spark added after, the way to change the login link will not work as described in the Laravel docs.
In order to change the login redirect route in Spark, it is actually really simple to do, but nowhere in the Spark docs will you see info on how to do it.
Steps to change redirect route.
- First, you need to go to your SparkServiceProvider in your app/Providers directory.
- Find the booted() method, and add the below code into that method.
Just replace new-route-here with your intended route and you should be good to go.
Hope this helps!
Thanks so much for visiting our blog.
I'm Chris, the owner of our small company.
Please reach out if you are needing help in some way! We may be able to serve you.
Thanks so much for reading. I hope you enjoy the content here.