laravel 5.4 yajra datatable cant query table by url id表示缺少必需参数

时间:2017-06-16 06:56:45

标签: laravel yajra-datatable

我想通过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']);

2 个答案:

答案 0 :(得分:1)

调用路径

时必须传递一个值

{{ route('medrep.getposts', ['id' => 1]) }}

答案 1 :(得分:0)

你应该在Request之后使用$ id参数:

public function getpostshow(Request $request,$id)

和请求参数为Request $request而不是request $request