Can't figure out simple task: join 1 table and add column. There is no useful documentation about service implementation here: DataTables as a Service Implementation
public function query()
{
$query = Technika::query()
->join('manufacturers','technika.manufacturer_id','=','manufacturers.id')
->select($this->getColumns());
return $this->applyScopes($query);
}
protected function getColumns()
{
return [
'manufacturers.id',
];
}
Above will trigger bizarre error
Requested unknown parameter 'manufacturers.id' for row 0, column 0
Tried many variations like:
return [
'id',
];
Above will trigger Column 'id' in field list is ambiguous
Another one was:
return [
[
'name' => 'id',
'data' => 'id'
]
];
this will result in: strtolower() expects parameter 1 to be string, array given
And so on and so forth. Maybe some one just can give basic join example using Service implementation?
System details
- Operating System OSX
- PHP Version 7.2
- Laravel Version 5.5
- Laravel-Datatables Version 8.0
Update #1
This one seams to be closest to working solution:
public function query()
{
$query = Technika::query()
->join('manufacturers','technika.manufacturer_id','=','manufacturers.id')
->select( $this->getColumns() );
return $this->applyScopes($query);
}
and
protected function getColumns()
{
return [
'technika.id',
'manufacturers.title'
];
}
But I'm getting Requested unknown parameter 'technika.id' for row 0, column 0.
However XHR response seams to be ok, I can see correct ata coming from backend.