Download the PHP package wdev-rs/laravel-datagrid without Composer

On this page you can find all versions of the php package wdev-rs/laravel-datagrid. 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 laravel-datagrid

LaravelDatagrid

Latest Version on Packagist Build Status Quality Score Total Downloads

This packages makes it easy to create data-grid for your Laravel application, for example admin panels, or any other searchable and sortable list. This package comes with 2 frontend options:

Both frontends offer server side functionalities like searching, sorting and pagination.

Laravel DataGrid

Demo

Please find a demo application here and the source code of the demo application here;

Installation

You can install the package via composer:

Optional - if you use Grid.js install the package with npm

Publish the vendor files by running the following command:

Using Grid.js frontend

Register the DataGrid fronted Vue.js component by adding the following lines to your app.js:

Use the component in your view file (or in another component):

Using Datagrid Vue 3 frontend

Register the DataGrid fronted Vue.js component by adding the following lines to your app.js:

Use the component in your view file (or in another component):

Usage

The base of this package is the \WdevRs\LaravelDatagrid\DataGrid\DataGrid class. This class is used to define the columns and the behavior of the datagrid. While you can use this class directly from the controller, I suggest extending it and create separate classes for each datagrid.

Using the fromQuery method you can define what should be the base query for the DataGrid. It accepts a Laravel Query Builder object. The column method is used to define the columns of the DataGrid, the argument are as follows:

The key method defines the unique identifier for the rows, usually id. Specifying the key is necessary for the mass actions to work when using datagrid frontend.

Data sources

You can create data grid from different data sources:

When the DataGrid definition is ready, you can add it to the controller:

If the render method is called without arguments it will use the default view resources/views/vendor/laravel-datagrid/datagrid.blade.php, or you can pass your own view and use the DataGrid there:

If you use Inertia for frontend, you can configire laravel-datagrid to use inertia for rendering instead of blade. First publish the config file:

Change the rendering method in the published config/laravel-datagrid.php:

Now you can pass the name of the vue component to the render method, it is going to be rendered with Inertia.

Available commands

Code related

php artisan make:datagrid <-M|--model> <-F|--fields>

Generates datagrid class, the generated class is placed in \App\DataGrids directory

  • -M|--model name of the model to use
  • -F|--fields the name of the fields of the comma separated: 'field1,field2,field3' or 'field1:label1,field2:label2,field3:label3'

Generated class

Usage example

Frontend customisations

Using Grid.js

The frontend component of the DataGrid can be found in the resources/js/vendor/laravel-datagrid/gridjs/Components/DataGrid.vue By default DataGrid comes with one row action, which is the delete action. This action can be found in the following file: resources/js/vendor/laravel-datagrid/gridjs/actions/delete.js

You can extend it with more custom actions by creating them based on the existing one. To add the to the datagrid, extend the cols definition in the DataGrid.vue:

Using Datagrid Vue3

Datagrid's own vue 3 frontend offers extended functionality compared to grid.js, for example mass actions, filters and row action customisations.

Mass actions

Mass actions is a method to run specific action on multiple records. For example delete multiple records at once.

When using mass actions I suggest using datagrid in a wrapper component. Mass actions can be defined using the mass-actions prop in an array [{'action' : 'massDelete', 'label': 'Delete'}]

Datagrid will fire an event when the user selects rows and runs an action on them. The name of the event is what you defined in the action property, in this case massDelete. Handle the event on the usual way, the handler gets the array of selectedIds as an argument:

Please find the code of the complete component below.

Customising the row actions

DataGrid by default adds 2 row action to all rows: edit and delete. You can easily customise these actions using the actions slot:

Customising the search

If you'd like to make a more detailed search function instead of the default search input field, use the filters slot.

Add your custom logic on the frontend for collecting the data and submitting to the search endpoint, using the ServerConfig class, for example:

On the backend override the search method of the base DataGrid class, to implement the custom filtering.

Please check out the demo application's source code for a more details about how to implement these customisations here: Laravel DataGrid demo

The demo app can be found here.

Upgrade from Laravel DataGrid 0.x

Update the vendor assets using --force option:

Using Grid.js

Using datagrid frontend

Update the import paths in the app.js to use correct DataGrid component (grid.js or datagrid), see the example above.

Update the usage of the data-grid component to pass the rows property:

Testing

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Laravel Package Boilerplate

This package was generated using the Laravel Package Boilerplate.


All versions of laravel-datagrid with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4|^8.0
illuminate/support Version ^6.0|^7.0|^8.0|^9.0|^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 wdev-rs/laravel-datagrid contains the following files

Loading the files please wait ....