jeudi 31 janvier 2019

How to run laravel route constrains before middleware?

I have route something like this /permissions/{uuid} And i have route constrain and middleware

Constrain Rule: Add in route service provider for all routes it will apply.

Route::pattern('uuid', '[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}');

Middleware Rule:

public function handle($request, Closure $next)
    {
        $uuid = $request->route('channel_uuid');

        //Check the uuid in db and throw exception

        return $next($request);
    }

But the problem here was the middleware was running first. I just want to avoid db call if uuid was not a proper format. Can we run constrain rule first.



from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2DOjvqC
via IFTTT

Aucun commentaire:

Enregistrer un commentaire