Support the ongoing development of Laravel.io →
Authentication

Defining in the routes.php if the method (the function in the class) needs authentication seems good. In that way we stop the request before it reaches the controller, but how is it done?

In the example in: https://laravel.com/docs/5.3/authentication#protecting-routes we see

Route::get('profile', function () { // Only authenticated users may enter... })->middleware('auth');

What if I want anyone to be able to see the index-method and only show the method extendedInfo to logged in users? Route::get('profile', function () { FreeForAll->ProfileController@index, Middleware-Auth->ProfileController@extendedInfo, });

Last updated 2 years ago.
0

NOTE! This forum does not accept my linebreaks

0

Sign in to participate in this thread!

Eventy

Your banner here too?

muppbarn muppbarn Joined 29 Mar 2016

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.