Download the PHP package teamq/laravel-datatables without Composer
On this page you can find all versions of the php package teamq/laravel-datatables. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download teamq/laravel-datatables
More information about teamq/laravel-datatables
Files in teamq/laravel-datatables
Package laravel-datatables
Short Description Custom filter and sorting set for 'spatie/laravel-query-builder' package
License MIT
Homepage https://github.com/teamq-ec/teamq-laravel-datatables
Informations about the package laravel-datatables
Laravel Datatable API
This is a collection of classes for filters and sorts, extending from the spatie/laravel-query-builder package, in addition to providing the possibility of applying these filters and sorting in related models using join through from the kirschbaum-development/eloquent-power-joins package.
Installation
You can install the package via composer:
You can publish the config file with:
This is the contents of the published config file:
Usage
Pagination
This package uses Laravel pagination by default; However, it allows you to specify through parameters of queries, the number of records to obtain, you can even obtain all the records.
It is recommended to use the result
method instead of paginate
or get
. Since result
encapsulates the logic of
both yes, it is requested to show all, below result
will use get
but if you want to see a number of records
below will use paginate
with the amount provided.
Filters
Filter | Class | Operators |
---|---|---|
Text | TeamQ\Datatables\Filters\TextFilter |
Text |
Number | TeamQ\Datatables\Filters\NumberFilter |
Number |
Date | TeamQ\Datatables\Filters\DateFilter |
Number |
Global | TeamQ\Datatables\Filters\GlobalFilter |
- |
HasRelationship | TeamQ\Datatables\Filters\HasRelationshipFilter |
- |
Text comparison operators
| Comparison operator | Key | |---------------------|---------------| | Equal | $eq | | Not Equal | $notEq | | Start With | $startWith | | Not Start With | $notStartWith | | End With | $endWith | | Not End With | $notEndWith | | Contains | $contains | | Not Contains | $notContains | | In | $in | | Not In | $notIn | | Filled | $filled | | Not Filled | $notFilled |Number comparison operators
| Comparison operator | Key | |-----------------------|-------------| | Equal | $eq | | Not Equal | $notEq | | Greater Than | $gt | | Greater Than Or Equal | $gte | | Less Than | $lt | | Less Than Or Equal | $lte | | Between | $between | | Not Between | $notBetween | | In | $in | | Not In | $notIn | | Filled | $filled | | Not Filled | $notFilled |You can use advanced filters that have support for multiple comparison operators.
The available comparison operators are located in TeamQ\Datatables\Enums\Comparators
To use these advanced filters, just call them as custom filters:
If you want to handle relationships using join, you must pass false
as the first parameter to the filter
and pass the type of join
to use.
Text Filter
The following example uses the comparison operator $endWith
isbn 54213
Number Filter
The following example uses the comparison operator $in
1, 5 or 9
For this example an array of values was used. Arraying values is supported by all types of operators (text and number).
Date Filter
The following example uses the comparison operator $notBetween
, created at 2019-08-01 and 2019-08-10
For this example an array of values was used. Arraying values is supported by all types of operators (text and number).
Global Filter
The global filter implements general search functionality for the model and its relationships.
This is not a global search engine between entities!!! For that you can use the package spatie/laravel-searchable
To use this filter, you must pass the model fields to be filtered or their relationships.
Has Relationship Filter
This filter accepts two possible values:
1
to filter by "Has"0
to filter by "Does not have"
Use this filter when you want the user to be able to filter on records that have associated models/relationships, For example, you may be interested in obtaining all authors who have books.
Sorts
Sort | Class |
---|---|
Relation | TeamQ\Datatables\Sorts\RelationSort |
Case | TeamQ\Datatables\Sorts\CaseSort |
RelationSort
To sort by fields of related tables you must use join
, there is no easy way to do it from eloquent,
so you can use RelationSort
, this class receives the type of join
as a parameter.
CaseSort
If you use enums or states, where each enum or state is represented by a number, you may want to sort by name
of that enum or state and not by the number, then you can use CaseSort
.
You must pass an array [$key => $value]
, which will be used to generate the sort.
As a second parameter you can specify the type of Join
that you want to use, if the ordering is by the field of a
related model. By default, it is Inner Join
.
Testing
Can use docker-compose to run
Changelog
Please see CHANGELOG for more information on what has changed recently.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- Luis Arce
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-datatables with dependencies
kirschbaum-development/eloquent-power-joins Version ^3.2
spatie/laravel-package-tools Version ^1.14.0
spatie/laravel-query-builder Version ^5.2|^6.0