Is it possible to link directly to a route, for example...
->addColumn('namelink', function ($users) {
return '<a href="redirect()->route('users.show').$users->id.'" ">'.$users->name.'</a>';
})
Just an example or something like that. Also what is the easiest way to link in the table so all the name result link to the show page as example.
I think the problem here is you use redirect()
and your route is not properly called. Just remove it and link should work fine.
->addColumn('namelink', function ($users) {
return '<a href="' . route('users.show', $users->id) .'">'.$users->name.'</a>';
})
Thanks for this snippet! Also, don't forget to call rawColumns
for unescaped HTML
return Datatables::of(User::query())
->addColumn('namelink', function ($user) {
return '<a href="' . route('users.show', $user->id) .'">'.$user->name.'</a>';
})
->rawColumns(['namelink'])
->make(true);
->editColumn('user_id', function ($data) {
return '<a href="/user/'.$data->user_id.'">'.$data->user_id.'</a>';
})
->rawColumns(['action','user_id'])
working fine thank @jpuck and @yajra
Thanks Brothers for this love
Most helpful comment
Thanks for this snippet! Also, don't forget to call
rawColumns
for unescaped HTML