i am using laravel 5.6 and for the service implementation i am using full package "yajra/laravel-datatables": "^1.0"
my problem is generated datatable last result id is repeating for action column, but rest of the columns in getColumns() functions displayed correctly.
any help or tips?. thanks
public function dataTable($query) {
return datatables($query)
->addColumn('action', function($q) {
return '<button>' . $q->id . '</button>'
}
}
public function query(User $model) {
return $model->newQuery()
->join('contacts', function($join) {
$join->on('users.id, '=', 'contacts.user_id')->orOn('users.id', '=', 'contacts.proxy_user_id');
})
->select('users.*', 'contacts.*')
}
anyway i found out the solution. query method is confusing with many id's while returning two table using asteriask. the better way only return needed column for the join table. hope someone find it useful
Please close the issue if you can, or provide a working solution and mark it solved.
We can all learn from each other here. Thanks!
@maxipy glad you found the solution. It's indeed needed to specifically include which columns to select to avoid confusions on laravel side which id to use.
@cudzich I think this is how he coded his solution:
->select('users.id as user_id', 'contacts.id as contact_id', 'users.name', etc..)
Most helpful comment
anyway i found out the solution. query method is confusing with many id's while returning two table using asteriask. the better way only return needed column for the join table. hope someone find it useful