[streams-platform] - How to set middleware on controller from addon service provider?
Created 2 years ago by lckamal

I have setup a middleware and added it to module service provider like this:

protected $middleware = [
        \Skrollx\JobsModule\Http\Middleware\CheckPackage::class,
    ];

But this middleware applies to all controller in this module. How to set middleware to use on a single controller?

dominique  —  2 years ago

Try setting it in your controllers construct function

public function __construct()
{
    $this->middleware(\Skrollx\JobsModule\Http\Middleware\CheckPackage::class);
}
lckamal  —  2 years ago

It worked! thanks. can we add parameter like we do in laravel? eg.. middleware('role:editor')

ryanthompson  —  2 years ago