Replies: 1 comment
-
It depends on your build. If you prefer to write your own js then https://datatables.yajrabox.com/eloquent/basic if the way to go. But personally, almost all my projects now uses the service class approach https://yajrabox.com/docs/laravel-datatables/master/quick-starter. This gives me full control on the columns, buttons and others scripts that should be conditionally added for the user on more of a laravel fluent way. For example, when using dataTables editor, there are user who are not allowed to create, update or remove a record. I can easily achieve it using the following code: Button:makeIfCan('users.create', 'create')->editor('editor'),
Button:makeIfCan('users.update', 'update')->editor('editor'),
Button:makeIfCan('users.delete', 'remove')->editor('editor'), If i need to export the table via server-side, I can just add this button: Button:make('csv'),
Button:make('excel'), Another tip: to make the common task reusable, I extracted them to its own class. This way, I can have a default styling too via php. Button:makeIfCan('users.create', 'create')->editor('editor')->className('btn btn-success')->formTitle('New Record')...etc,
// becomes
CreateButton::makeIfCan('users.create'), |
Beta Was this translation helpful? Give feedback.
-
Hi @yajra
I just want to ask what is the prepared way to use your package, I have already installed this version yajra/laravel-datatables-oracle:"~9.0" to my local.
when I use this package I code like before like this your examples https://datatables.yajrabox.com/eloquent/basic
but I saw this also https://yajrabox.com/docs/laravel-datatables/master/quick-starter on how to use your package
which one will you recommend to the proper way of using your package?
Thank you in advance.
Beta Was this translation helpful? Give feedback.
All reactions