Stackers! I'm currently learning laravel5 and I love it, but I'm struggling with one thing. Since Laravel 5 we have Middleware which we can use in controller's construct function, like this:
Controller file:
public function __construct()
{
$this->middleware('admin', ['only' => 'create']);
}
Now what I want is to define HERE^ (not in routes file) middleware to be used in multiple views, like 'create', 'edit' and 'show'. defining
public function __construct()
{
$this->middleware('admin', ['only' => 'create|edit|show']);
}
Unfortunately does not work. I'd rather not use routes. Any ideas, dear friends?
Simply pass an array instead of a string with |
delimiter:
public function __construct()
{
$this->middleware('admin', ['only' => ['create', 'edit', 'show']]);
}