我有来自DataTables的列表<a href="pegawai/view/'.$pegawais->id_pegawai.'"
,我在其中添加了编辑和删除按钮,但如果用户输入手册,则仍为静态/
,最后有example.com/pegawai/
类example.com/pegawai/pegawai/edit/{id}
1}}它将成为class
所以我想使用route()它可以吗?因为我试过它,只是在public function data(Request $req)
{
DB::statement(DB::raw('set @rownum=0'));
$pegawai = Pegawai::select(
DB::raw('@rownum := @rownum + 1 AS rownum'),
"pegawai.id_pegawai",
"pegawai.nama",
"pegawai.nip",
"pegawai.id_jabatan",
"pegawai.id_unit_kerja",
"jabatan.nama_jabatan",
"unit_kerja.nama_unit_kerja"
)
->Join("jabatan","pegawai.id_jabatan","=","jabatan.id_jabatan")
->join("unit_kerja","pegawai.id_unit_kerja","=","unit_kerja.id_unit_kerja");
$datatables = Datatables::of($pegawai)
->addColumn('action', function ($pegawais) {
return '
<a href="pegawai/view/'.$pegawais->id_pegawai.'" class="btn btn-sm btn-primary"><i class="fa fa-eye"></i></a>
<a href="pegawai/edit/'.$pegawais->id_pegawai.'" class="btn btn-sm btn-warning"><i class="fa fa-edit"></i></a>
<a href="pegawai/delete/'.$pegawais->id_pegawai.'" class="btn btn-sm btn-danger"><i class="fa fa-trash"></i></a>
<a href="pegawai/cetak_data/'.$pegawais->id_pegawai.'" class="btn btn-sm btn-success"><i class="fa fa-print"></i></a>
';
})
->editColumn('id_pegawai', '{{ $id_pegawai }}');
if ($keyword = $req->get('search')['value']) {
$datatables->filterColumn('rownum', 'whereRaw', '@rownum + 1 like ?', ["%{$keyword}%"]);
}
return $datatables->make(true);
}
标记
这是我的完整DataTales代码
<a href="{{ route("pegawai.edit", $pegawai->id_pegawai) }}"
如何在$("#fromdate, #todate").click(function () {
$('frameset', top.document).eq(2).attr('rows', '300,*');
});
答案 0 :(得分:0)
您的链接应为:
pegawai/'.$pegawais->id_pegawai.'/show
pegawai/'.$pegawais->id_pegawai.'/edit
pegawai/'.$pegawais->id_pegawai.'/destroy
如果您正确设置路线,Laravel应自动选择这些路线。
答案 1 :(得分:0)
我已将此传递路径解析为数据表按钮
<a href="'. route("pengelolaan-surat.view", $pengelolaans->id_surat) .'"><i class="fa fa-eye"></i></a>