0
votes

I have a route resource

Route::resource('campaign', 'CampaignController');

I want to restrict some of these routes to the users.

For example the index page lists all the campaigns and they should not see this only their own ones.

I have a custom middleware that simply checks the if the user is an admin

However I cannot apply this to individual methods.

public function index()
    {
      $this->middleware('checkuser'); 

    }

Just the constructor

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

How do I get around this and apply to individual route in the controller

1

1 Answers

0
votes

Sorry my mistake I should have read the docs you can add exceptions or allowed.

$this->middleware('auth');

 $this->middleware('log', ['only' => ['fooAction', 'barAction']]);

$this->middleware('subscribed', ['except' => ['fooAction', 'barAction']]);
    }