在Laravel 5.4中单击Button时,将Id从一个视图传递到另一个视图

时间:2017-12-06 13:36:32

标签: laravel-5

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

我的路线是传递ID:Id是我想从一个视图传递到另一个视图并显示在第二个视图中

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

我要显示的控制器功能是:     公共功能节目($ Id)     {}

它让我错误地说:

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.

1 个答案:

答案 0 :(得分:1)

试试这个:

<强>路线

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

<强>控制器

public function show($id) {}

<强>刀片

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