santosh limbu thebe
santosh limbu thebe

Reputation: 59

Passing Id from one view to another when Button is clicked in Laravel 5.4

I am using response from xml server. I am trying to display the different detail view when each BUtton is pressed respectively.When the Button is pressed, I want to send the Id of each button to the detailed page and I want to display that Id on the detailed page too.


My Button for clicking and passing ID to next view respective to each button clicked is: 

 <a href='{{route('Detailed',["Id" => $flight["Id"]])}}'>SELECT NOW</a>  
$flight["Id"] is the response value that I get from the xml server

My route is for passing Id is: Id is what I want to pass from one view to another and display in second view

Route::get('/Detailed/{Id}',[ 
        'as' => 'Detailed', 'uses'=>'FlightController@show'
]);

My controller function to display is: public function show($Id) {}

It gives me error saying that:

Missing required parameters for [Route: Detailed] [URI: Detailed/{Id}] in view.blade.php. 
Please anyone help me

But if give direct value in button route 
such as ID value then,

<a href='{{route('Detailed',["Id" => "1234"])}}'>SELECT NOW</a>  

It works exactly what I expect.

Notes the Id value that I get is from simple_xml_response from server.

Upvotes: 1

Views: 1933

Answers (1)

Sam_Benne
Sam_Benne

Reputation: 615

Try this:

Route

Route::get('detailed/{id}', 'FlightController@show')->name('detailed');

Controller

public function show($id) {}

Blade

<a href='{{route('detailed', '1234')}}'>SELECT NOW</a>  

Upvotes: 1

Related Questions