我想通过yajra datatable中的url id查询表,但我无法查询缺少的参数。
控制器
public function getpostshow($id,request $request)
{
$medrep = Medrep::find($id);
$req = $request->segment(2);
$users = DB::table('itinerarys')
->select('doctors.*','medreps.*','itinerarys.*')
->join('doctors', 'itinerarys.doctor', '=', 'doctors.doctor_id')
->join('medreps', 'itinerarys.medrep', '=', 'medreps.medrep_id')
->where('itinerarys.medrep', '=', $req);
return Datatables::of($users)
->editColumn('EmployeeLastName', '{!! str_limit($EmployeeLastName, 60) !!}')
->editColumn('CustomerCode', '{!! str_limit($CustomerCode, 60) !!}')
->editColumn('CustomerLastName', '{!! str_limit($CustomerLastName, 60) !!}')
->make(true);
}
路线
Route::get('medrep/{id}/getpostshow',
['as'=>'medrep.getpostshow','uses'=>'MedrepController@getpostshow']);
答案 0 :(得分:1)
调用路径
时必须传递一个值 {{ route('medrep.getposts', ['id' => 1]) }}
答案 1 :(得分:0)
你应该在Request之后使用$ id参数:
public function getpostshow(Request $request,$id)
和请求参数为Request $request
而不是request $request