Closed johnneijzen closed 8 months ago
how to use $exportable function with columns from other tables?
<?php namespace App\Livewire; use App\Models\Employee; use Arm092\LivewireDatatables\Column; use Arm092\LivewireDatatables\Livewire\LivewireDatatable; use Arm092\LivewireDatatables\NumberColumn; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Model; class EmployeesTable extends LivewireDatatable { public string|null|Model $model = null; public bool $exportable = true; public function builder(): Builder { return Employee::query(); } public function getColumns(): array|Model { return [ NumberColumn::name('id') ->label('ID'), Column::name('first_name') ->defaultSort('asc') ->label('First Name') ->searchable(), Column::name('middle_name') ->label('Middle Name') ->searchable(), Column::name('last_name') ->label('Last Name') ->searchable(), Column::name('birthday') ->label('Birthday'), Column::name('address.line_address') ->label('Address') ->searchable(), Column::name('address.city.name') ->label('City') ->searchable(), Column::name('address.city.province.name') ->label('Province'), Column::callback(['id'], function ($id) { return view('employees.actions', ['id' => $id]); })->excludeFromExport(), ]; } }
and i have this error when export button and here is error logs if need them https://flareapp.io/share/x7XZkzVm i
Try to join addresses table and write column names in plural mode (addresses.line_address). I do such things in this way
addresses
addresses.line_address
how to use $exportable function with columns from other tables?
and i have this error when export button and here is error logs if need them https://flareapp.io/share/x7XZkzVm i![image](https://github.com/arm092/livewire-datatables/assets/1343960/771b581a-051f-44ba-9f93-0f5445a53be1)