在我的Web文件中,有一条路由接受一个$id作为传递给PagesController中函数的值。然而,即使$id未被传递到函数中,我仍希望函数能够执行并显示预期的表格。
web.php文件:
我希望页面能够显示来自数据库的详细信息,当提供$id时,或者在$id未提供时保留空格。
web.php文件:
Route::get('/request/{id}', 'PagesController@makeRequest');
PagesController.php文件
public function makeRequest($id)
{
if(!empty($id)){
$target = Partner::find($id);
}
return view('pages.makeRequest')->with('target', $target);
}
makeRequest.blade.php
<input type="text" class="form-control" value="{{$target->inst_name}}" required disabled>
我希望页面能够显示来自数据库的详细信息,当提供$id时,或者在$id未提供时保留空格。