How to Restrict Laravel Controller Access to Authenticated Users.
First approach is based on the routes, we add the middleware restriction with in our projects routes.php file. For instance we have a user dashboard function and we want allow access only authenticated users. To do this you can use the following code.
After that you see now only signed in user access the dashboard function or page.
Second approach is based on the controller, we add the middleware restriction within controller constructor to do this use the following code.