How to send value "{{$ item-> id}}" to some method in a controller?
e.g. show.blade.php - contains the value:
"{{$ item-> id}}"
MyController.php - contains the method:
public function results(Request $request){
//and here I want to use the value {{$ item-> id}}
}
答案 0 :(得分:2)
Just make a form and post it , or have some hyperlink
<form method="POST" action="/route_to_your_controller">
{{ csrf_field() }}
<input type="hidden" name="item_id" value="{{$item->id}}" required>
</form>
Route
Route::post('/route_to_your_controller', 'yourController@results');
Controller
public function results(Request $request){
{
$name = $request->input('item_id')
}
答案 1 :(得分:0)
在你的MyController中使用
public function results(Request $request, Item $item){
//and here I want to use the value {{$ item-> id}}
$item_id = $item->id;
}
您还可以访问项目的所有字段。