Download the PHP package dongrim/datatable-inertia without Composer
On this page you can find all versions of the php package dongrim/datatable-inertia. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package datatable-inertia
Datatable-Inertia
This package provides a DataTables-like experience for Inertia.js with support for searching, filtering, sorting and pagination.
Laravel compatibility
Laravel | datatable-inertia |
---|---|
6.0-9.x | 0.0.x |
Installation
Install the package via composer.
Config Files
In order to edit the default configuration you may execute:
Usage
-
Generate a datatable
By default, the command generates the SomeDatatable
class in the \App\Datatables directory
If you want to change the destination path of a class, you can use one of these methods:
-
Specify a new path in the file /config/datatables.php
- Run command
php artisan datatable:make
without specifying the name of the generated class and answer questions.
-
How to use in Controller
To generate data, a table
macro has been created for Inertia\Response.
You can take advantage of dependency injection
Or just give the classpath
If you need to pass additional data, use the usual method of passing data in InertiaJs
-
How to use Datatable class
By default datatable class is generated in minimal configuration
For example
Public properties available in the class:
Properties | Type | Default | Description |
---|---|---|---|
datatableName |
string | 'datatable' | The name of the object containing all returned data from datatable |
perPageKey |
string | 'per_page' | The key in the request responsible for changing the number of displayed elements on the page (only when rendering on the client side) |
itemsPerPage |
int | 15 | Parameter responsible for the number of displayed elements on the page by default |
serverSide |
bool | false | Parameter responsible for the server or client side rendering |
Note that these options are set globally in the config/datatables.php configuration file.
You can override them directly in you the class
Public methods available in the class:
Method | Response type | Required | Description |
---|---|---|---|
query |
\Illuminate\Database\Eloquent\Builder |
required |
Creates prepared Eloquent query builder |
modify |
\Illuminate\Database\Eloquent\Model |
optional |
Changing the value of returned fields |
columns |
array |
optional |
If method columns not implemented in the derived class, will be returned all fillable fields |
guard |
array |
optional |
Adding access rights to a specific entry to change, delete, etc. |
filters |
array |
optional |
Adding filters and their values (server-side rendering only) |
For ExampleDatatable: