1
votes

I have a route group which is protected by the auth middleware, and inside of this group I want to except one route. But this route is also located in another route group. So when I try to move it out of this group, it is not working.

How can I fix this problem, and except a UrlProfile function from auth middleware?.. I am using Laravel 5.1

Route::group(['middleware' => 'auth'], function () {

    // some other routes ...

    Route::group(['namespace' => 'Lawyer'], function() {
        Route::get('profile/{name}', 'ProfileController@UrlProfile');
    }

};
2

2 Answers

1
votes

Can you try this?

Route::group(['namespace' => 'Lawyer'], function () {

    Route::get('profile/{name}', 'ProfileController@UrlProfile');

    Route::group(['middleware' => 'auth'], function() {

        ..
        ..
        ..

    )};

)};
1
votes

If I understood your problem correctly, This should also work.
You can add this in your controller.
You can insert the name of your function in the except section and it will be excluded from the middleware. [Reference]

public function __construct()
    {
        $this->middleware('auth')->except(['yourFunctionName']);
    }