mercredi 27 septembre 2017

Middleware on route and in controller

I am attempting to run middleware on specific routes as well as inside controller constructor, however it appears middlewares that are defined inside the controller constructor are not being executed for the routes that include middleware. Is this not possible? (all of these middleware are registered in kernel.php, all middleware in constructor working before adding middleware to route)

Route

Route::get('/{organization_slug}', function($organization_slug){

    $organization = \App\Organization::where('slug', '=', $organization_slug)->first();

    $app = app();
    $controller = $app->make('\App\Http\Controllers\OrganizationController');
    return $controller->callAction('details', $parameters = array($organization->id));

})->middleware('verifyorganizationslug');

Controller Constructor

    public function __construct()
    {
        $this->middleware('auth', ['only' => ['create', 'update', 'store']]);
        $this->middleware('accountactive', ['only' => ['create', 'update', 'store']]);
        $this->middleware('ownsorganization', ['only' => ['update']]);
        $this->middleware('verifyorganization', ['only' => ['details']]);

    }



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2wUqnRo
via IFTTT

Aucun commentaire:

Enregistrer un commentaire