D
D
David2016-06-23 00:21:18
Laravel
David, 2016-06-23 00:21:18

Request and data from routes in Laravel?

The essence of the question is this: how to check in intermediaries (middleware) the data that is transmitted using routes?
For example, there is a route:

Route::get('somedata/{id}', ['middleware' =>'check.somedata', 'uses' => '[email protected]']);

How to pull out in the intermediary idto check its existence, etc.? There are suspicions that using Request, but there is nothing like that in the documentation?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Igor, 2016-06-23
@MiragePresent

class MyMiddleware implements Middleware
{
    public function handle($request, Closure $next)
    {
        $id = $request->route('id');
        //stuff...
        $next($request);
    }
}

And yet, the method $request->route()->parameters();can get all the parameters.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question