D
D
Denis2021-11-15 17:34:23
Laravel
Denis, 2021-11-15 17:34:23

How to pass parameters to laravel?

Meet Laravel. There is a small application until the test version sketched. The essence such is 1 page on which the form with 5 filters. We press send and if there is data for such a request, the request data appears below the form, which filter parameters were used, and the data itself is in the table below.
If there is no data, then an empty table and the session pops up that no data was found.

Now conditionally on this page there are 2 methods.
1 get on first entry. I pass parameters for filters and send them to the view.
2 method on the same page but post. Accepts filters, processes. And gives the answer.
if there is data, then I simply pass to the view what was found and the filter parameters.
If there is no result, I did it in the same post method
return back()->with('sessionKey', 'msg');
But now it was necessary to pass which filters were used in the request.
I don’t understand how to transfer them when redirecting?) Or just send data to the view as if the data was found, without a redirect? Something like

return view('viewName', compact('param1',  'param2'));

but then ->with('sessionKey', 'msg') doesn't work, I tried to prescribe after view .
Or what's right?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey delphinpro, 2021-11-15
@delphinpro

Filters are usually made into a normal get-request, passing parameters in get-parameters. Accordingly, no redirects are needed, we simply get the get parameters from request

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question