Download the PHP package team383/data-table-laravel without Composer

On this page you can find all versions of the php package team383/data-table-laravel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package data-table-laravel

383's Data Table (Laravel Package)

This package provides a simple way to create the back end for a data table in Laravel. It is designed to work with our React Data Table package, and could later include other front end packages as well.

The purpose of the data table is relatively simple and common; to provide a table of data that can be sorted, filtered, searched and paginated.

This back end portion focusses on providing a good Laravel-esque interface you can use with your Eloquent models in order to provide controllers for your data tables in a uniform way.

Installation

You can install the package via composer:

Data Table Controllers

The data table controller is the core of this package. Each data table needs a controller in order to define how the data is retrieved. This package provides a base data table controller that you can extend to create your own data table controllers.

The only feature you must provide is the query method, which should return a query builder instance that will be used to retrieve the data for the data table, but there are a number of other properties and methods you can override or provide to customise the behaviour of the data table.

Hidden Fields

Sometimes you need data to be available to the front end code, but do not want it to be displayed as a column in the table. You can define hidden fields in your data table controller either by providing a $hidden_fields property or, if you require more complex behaviour, by overriding the getHiddenFields method.

Field Labels

By default, the field labels will be taken from the field names; these will be have all non-alphanumeric characters converted to single spaces and the string will be converted to title case (for example my-weird_field&&&name => My Wierd Field Name). You can override this behaviour by providing a $field_labels property or by overriding the getFieldLabels method.

It's worth noting that the default implementation of getFieldLabels contains the logic which converts any field names missing from the $field_labels property to title case, so if you override this method you may want to provide an alternative implementation or you will be at the mercy of the front end's fallback.

Sortable, Searchable and Filterable Fields

This package allows you a great deal of control over which fields are sortable, searchable and filterable; let's define what these terms mean:

Note that by default the search functionality uses a text input, whereas the filters use an array structure

Sorting

In order to make a field sortable, simply add it to the $sortable_fields property of the controller; this will work automatically for simple sorting (ie where the corresponding database query is just ORDER BY field ASC/DESC), but for more complex queries you will need to provide a sort method.

This is done by creating a method that begins with sort followed by the field name of the field in pascal case (making the function name camel case); this method should take two arguments, the query builder and the direction of the sort (either asc or desc); for example a common case may be where we have concatenated first and last names, but we need to sort against the full name - for this example let's assume we also want to sort by last_name first as well:

Searching

In order to make a field searchable, simply add it to the $searchable_fields property of the controller; this will work automatically for simple searches (ie where the corresponding database query is just WHERE field LIKE %search_term%), but for more complex queries you will need to provide a search method.

This is done by creating a method that begins with search followed by the field name of the field in pascal case (making the function name camel case); this method should take two arguments, the query builder and the search term; for example a common case may be where we have concatenated first and last names, but we need to search against the full name:

Filtering

In order to make a field filterable, simply add it to the $filterable_fields property of the controller; this will work automatically for simple filters (ie where the corresponding database query is just WHERE field = filter_value for a simple string, or WHERE field IN (values) where an array is given), but for more complex queries you will need to provide a filter method.

This is done by creating a method that begins with filter followed by the field name of the field in pascal case (making the function name camel case); this method should take two arguments, the query builder and the filter value; for example a common case may be where we have a status field that is an integer, but we want to filter against a string representation of a list of statuses:

When the front end requests filters, this should be provided in a filter array, where the key is the field name and the value is the filter value; for example:

This example would filter the data to only show records where the brand is Honda, the type is either car or motorcycle, and the status is new, used or damaged (according to the example custom method above)

Resource Classes

By default, the controller will use the DefaultDataTableResource to format its output, but you can provide a custom resource class by setting the $resource_class property or overriding the getResourceClass method of the controller.

Whichever resource class you use, the response will have a few properties added to its metadata which are used by the front end:

These properties are used by the front end to determine how to display the data table and what options to provide to the user.


All versions of data-table-laravel with dependencies

PHP Build Version
Package Version
Requires php Version ^8.4
spatie/laravel-package-tools Version ^1.16
illuminate/contracts Version ^10.0||^11.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package team383/data-table-laravel contains the following files

Loading the files please wait ....