Laravel 5.4 Database Placement Questions

john david posted 11 months ago

I know how I can get the data needed, but want to follow Laravel/MVC practices here and new to it.

I have a page that stores data that a user sends through a form. Once they submit they are redirected to a new page that I'd like to display some of the data back to them.

For example, currently any data I want to display I'm just passing in the URL.

$trip = new Trip; $trip->tripName = request('tripName'); $trip->departing = date('Y-m-d H:i:s', strtotime(request('departing'))); $trip->returning = date('Y-m-d H:i:s', strtotime(request('returning'))); $trip->save(); $tripID = $trip->id; $tripName = request('tripName');

    return redirect()->route('flight', ['tripID' => $tripID,'tripName' => $tripName]);

Then within the view I just:

{{ $_GET['tripName'] }} Is that how I should be doing it? Or when they hit the new view is there an easy way to grab that data with a DB call? If so should this be done in the view or do I need to serve somehow from the controller?


Sign in to participate in this thread!

We'd like to thank these amazing companies for supporting us