livewire-datatables
livewire-datatables copied to clipboard
error SQLSTATE[42S22] - 1054 with export
Hi
when I export some datatable I have this message:
SQLSTATE[42S22]: Column not found: 1054 Unknown column
The column is a relation like : post.name
My config
"php": "^7.3|^8.0", ->php 7.4
"bonecms/laravel-captcha": "^2.2",
"fideloper/proxy": "^4.4",
"fruitcake/laravel-cors": "^2.0",
"guzzlehttp/guzzle": "^6.5",
"intervention/image": "^2.7",
"laravel-frontend-presets/tall": "^3.1",
"laravel-lang/lang": "~8.0",
"laravel/fortify": "^1.7",
"laravel/framework": "^8.12",
"laravel/horizon": "^5.9",
"laravel/tinker": "^2.5",
"livewire-ui/modal": "^1.0",
"livewire/livewire": "^2.4",
"mediconesystems/livewire-datatables": "^0.7.0",
"phpsa/laravel-yourls-plugin": "^1.2"
someone to help me ? ;)
the same issue. please @marksalmon look at this
@marksalmon @thyseus @tomshaw @trippo please help
when exporting datatable, there is error "Unknown column", and no JOINS in query
the same issue. please @marksalmon look at this
@Slobug @arlanram @mansiprajapati I need to narrow down the issue. There's no way I can reproduce the error without more detail. I haven't looked at the library in a while so I downloaded the latest Laravel/Jetstream Livewire. Factoried a few hundred users. Cloned the latest livewire-data tables and created a user grid. I was unable recreate any errors.
@tomshaw Try to add a relation column in the data table and export the data this way you can regenerate this error
@mansiprajapati Can I see your column type.
I have found out that export didn't work for me for same reasons as long as I was using public $model, but when I used the query builder, it worked. Does that help?
I have found out that export didn't work for me for same reasons as long as I was using public $model, but when I used the query builder, it worked. Does that help?
I @nathcast ,
Thank you very much for your help. I had to put my problem on hold but thanks to you and a little digging through the code in the vendor folder, I was able to solve my problem.
If it helps anyone, if you want a custom export :
add : use Illuminate\Support\Facades\DB;
public $exportable = false; public $customexportable = true;
with this, the "export" button will return to a custom function "customexport".
` public function customexport() {
$data = DB::table('table1')
->select(
'table1.column',
'table1.columNameLikeTable2 AS otherName_a',
'table2.discipline',
'table2.columNameLikeTable1 AS otherName_b',
)
->leftJoin('table2', 'table2.id', '=', 'table1.user_id')
->get();
$export = new DatatableExport($data);
return $export->download();
}`