I am using Yarja datatables for quite a complex table set and also have the ajax part returning two buttons:
{
$user = Auth::user();
$cl = $user->client_id;
$jb = DB::table('job')
->join('job_status', 'job.jobStatus_id', '=', 'job_status.id')
->join('customers', 'job.customer_id', '=', 'customers.id')
->join('users', 'job.operative_id', 'users.id')
->where('job.client_id', $cl)
->select(['job.id as id', 'job_status.status as status', 'job.customer_id as customer_id', 'customers.customer as customer', 'users.name as operative','job.address as address','job.postcode as postcode','job.slug as slug','job_status.id as jobStatusID'])
->get();
return Datatables::of($jb)
->addColumn('action', function($pubs){
$btn = '<div style="float:right">
<a href="#" class="btn btn-outline-secondary btn-xs" title="show details" style="margin-right:.5em;font-size:.75em"><i class="fas fa-book" ></i></a><a href="#" class="btn btn-outline-secondary btn-xs" title="show details" style="margin-right:.5em;font-size:.75em"><i class="fas fa-edit" ></i></a></div>';
return $btn;
})
->make(true);
}
This works fine but now I want to add an action to the buttons, initially the edit, which is the route and the id of the row. As you can see I have replaced the # with the route so I have
"admin\jobView"
but I cannot seem to work out a way of adding a field from the query (specifically jb->id) so that the action would be something like
admin\jobView\123
Just can't seem to get it and would greatly appreciate some help!