vendredi 30 mars 2018

Laravel - View with multiple attributes, URL only with ID

I'm trying to give attributes to a view (So i can use them in blade) while in the route it only requires the ID. let me explain

The route I'm talking about is Route::get('/order/{id}', 'OrderController@show'); now in that particular show method, I want to return a view with the $order variable another variable called $payment which consists of some information. So that I can use them in blade. Thats show method looks like this

public function show(Order $order, $payment)
{
    return view('orders.show', compact('order', 'payment'));
}

In that same controller I have a store method and when everything inside that method is executed it redirects to the show method by doing this

return $this->show($order, $payment);

But when the store method is executed and the order is shown. The URL is order/26/store instead of order/26. presumably because I use

return view('orders.show', compact('order', 'payment')); in the show method.

How can I make it so I can use both the variables (In blade) while the route looks like 'order/26' Instead of order/26/store

Both routes I'm talking about are listed here.

Route::get('/order/{id}/store', 'OrderController@store')->name('storeOrder');
Route::get('/order/{id}', 'OrderController@show')->name('showConfirm');



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire