T
T
Temper52017-02-09 19:54:27
Laravel
Temper5, 2017-02-09 19:54:27

How to pass data from mediator to controller?

I thought that I could exclude additional checks from the controller by doing it all in midddleware. That is, it is necessary to transfer a variable from the intermediary to the controller, depending on the value of which certain actions will be performed. Question: how can I pass a variable from an intermediary to a controller?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Victor, 2017-02-09
@v_decadence

In controller constructor

$this->middleware(function ($request, $next) {
    // $this->variable = 10;

    return $next($request);
});

K
Kirill Nesmeyanov, 2017-02-12
@SerafimArts

Add value to container and then push it through DI or service location?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question