V
V
Vanya Huk2018-07-01 20:59:08
Laravel
Vanya Huk, 2018-07-01 20:59:08

How to pass middleware parameters to laravel from controller?

is it possible to somehow pass parameters from the controller to the middleware?
5b39166a44558663215440.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
B
Barmunk, 2018-07-02
@Barmunk

Use request()

//принять в middleware 
dd($request->route(null));
dd($request->input(null));
dd($request);

//передать из middleware 
$request->newData = $data;

S
Sergey Chazov, 2019-04-07
@chazovs

If you need to use a parameter in the intermediary that is passed to the controller from the route, then you can use the id construct, in this case it is passed to the controller from the router
And it gets into the router out of sight
{{ route('companyHome',['id'=>$company->id]) }}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question