简体   繁体   中英

How can I send data from one page to another using Laravel?

So I'm using laravel 5.1 and I'm stuck in a weird situation.

I have 2 models Season and Tournament and lets say the url to add a Season model is ..../seasons/add and to view the season would be ..../seasons/(id) ... standard stuff right?

But now I want to add a tournament from the link ..../seasons/1 and so I click a link that takes me to ..../tournaments/add ... how can I send the Season model to that page without submitting a form with hidden input?

Currently I have this setup ..../seasons/1/tournaments/add using blade to generate the links. But this method just doesn't feel right....

Thanks.

How can I send data from one page to another using Laravel? : I would suggest that you do this from your controller. Take a look at Redirecting With Flashed Session Data , it might come in handy.

From the Flash Data documentation: "[...] it will only be available during the subsequent HTTP request, and then will be deleted [...]"

You can send your model, static values or whatever you want using ->with:

redirect('route')->with('key', 'value');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM