Support the ongoing development of Laravel.io →
Authentication

I have a restful route controller for user setup like this:

 Route::resource('user', 'UserController');

I am able to use the auth middleware in the UserController like this:

 public function __construct()
{
	$this->middleware('auth');
}

But how can I apply a different middleware (or both) to the edit, update and destroy routes as $this->middleware('auth') cannot be used inside a function?

Last updated 3 years ago.
0

Have you not tried adding additional route method to the Route::resource and creating or adding another middleware?

0

I think you can add additional Routes to Resource controllers, example below,

Route::get('photos/popular');

Route::resource('photos', 'PhotoController');

check the documentation, http://laravel.com/docs/5.0/controllers

Last updated 10 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

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.