I have a return in my controller like this:
return view('frontend.bike')->with('message', 'Bike Created');
It directs correctly view, however I want to pass it two variables that are needed. Currently I have it routing via:
Route::get('b/{bikename}/{type?}', ['as' => 'bike', 'uses' => 'FrontendController@bike']);
How can I include a bikename and type to the return to make sure it goes to the correct page.
you can get those route variable in controller as below in function arguments,
public function bike($bikename, $type = null){
$type = $type ? $type:'N/A'; //optional
$message = 'Bike Created';
return view('frontend.bike', compact('message', 'bikename', 'type'));
}
in views/frontend/bike.blade.php,
{{ $message }}
{{ $bikename }}
{{ $type }}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With