-
-
Notifications
You must be signed in to change notification settings - Fork 157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Working with Laravel Datatables #113
Comments
Could you get into more detail what your problem is? |
I want to display one locale in columns. I am able to bring the data and the json returns correctly. There are two issues #2 While searching or sorting the table. Datatables runs queries which is not compatible for translations. I know I have represented the questions and sorry about that. I can explain more. |
I'm not this deep in the other package. Some ideas you could try to play with: For sorting you could try https://docs.astrotomic.info/laravel-translatable/package/scopes#orderbytranslation-string-usdtranslationfield-string-usdsortmethod-asc - I bet that the datatable package accepts custom order queries/scopes in any way. At the end you will have to dig deeper into the datatable package. But I would be fine/happy to accept a PR in the docs to add guides for how to do it. Except of this: I wish you and your loved ones a Merry Christmas! |
Thank you for your suggestios. Your wish made me smile. Thank you. |
I have some issues with datatables as well. When using server-side, we don't use get() in the Eloquent model, so the translations are not loaded at all and the search in a translatable field will not be present in the query, so we need to define the filterColumn method in the datatable. $datas = Generalsetting::orderBy('id');
//--- Integrating This Collection Into Datatables
return Datatables::of($datas)
->filterColumn('title', function ($query, $keyword) {
$query->whereTranslationLike('title', "%{$keyword}%", $this->lang->locale);
})
->toJson(); //--- Returning Json Data To Client Side Also, I tried to select just a few data, like id and title, and title is translatable, but using Model::select('id','title') does not work, because the translations table is not loaded at all for the query to work. That makes queries slower with lots of data. It should be possible to select the fields we want in select with translations, like: $datas = Generalsetting::select('id','title')->orderBy('id'); I tried to chain the call using EDIT: I forgot to ping you @Gummibeer as it is a closed issue but with new information |
@weidmaster so far I've understand it your issue is that If anyone comes up with a working solution that is maintainable I will happily merge it, but even the PHP memory issue is solvable with LazyCollections right now. 🎉 |
I have checked and it seems like it is hard to work if we are using laravel data tables package
Does it work with that package.
Is there any documentation available
The text was updated successfully, but these errors were encountered: