viveksingh/dynamic-datatable

v1.0.0 2023-03-13 11:26 UTC

This package is auto-updated.

Last update: 2024-05-16 14:31:01 UTC


README

Latest Version on Packagist Total Downloads

This Laravel package is a useful tool that allows developers to easily create and manage dynamic data tables in their Laravel applications. With this package, you can quickly generate dynamic tables that are fully customizable and support a variety of data types, including text, numbers, dates, and more.

The package offers a range of features to help you build powerful data tables with minimal effort. For example, you can sort and filter data, paginate tables, add custom columns.

One of the key benefits of your package is its flexibility and ease of use. Whether you're building a simple table to display basic data or a complex table with advanced functionality, the package provides a straightforward interface that makes it easy to create, manage, and customize your tables.

Installation

You can install the package via composer:

composer require viveksingh/dynamic-datatable

Usage

The DynamicDatatable::table($request) method is used to generate a dynamic data table using your Laravel package for dynamic-datatables.

To use this method, you will first need to ensure that your package is properly installed and configured in your Laravel application. Once you have done so, you can call the table() method and pass in a $request object recieved from jquery datatable ajax request.

    public function getData(Request $request){        
        return DynamicDatatable::table($request);    
    }

You can also pass table name from the controller like this:

    public function getData(Request $request){        
        return DynamicDatatable::table($request, 'table_name');    
    }

And In the front file where we implement jquery table lookes like this:

 $(document).ready(function() {
        $('#table').DataTable({
            processing: true,
            serverSide: true,
            paging: true,
            ajax: {
                url: "{{ route('admin.getUser') }}",
                data: {
                    table_name: 'users'
                }
            },
            columns: [{
                    data: 'id',
                },
                {
                    data: 'name',
                },
                {
                    data: 'email',
                }
            ],
        });
    });

Here paging must be true and you pass the column names which you want to use in the datatable. and one important thing you can also pass the table name from the ajax data . for more please see the examples.

Testing

composer test

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 viveksingh.hestabit@gmail.com 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.