Download the PHP package gustocoder/laravel-datatable without Composer

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

Laravel datatable package

Instantly generate beautiful tables from your Laravel models

Example Users table

How to use it

Install it

After installation The configuration file will be created for you in:

  'config/laravel-datatable.php'

The stylesheets should be created for you in:

  'public/vendor/datatable.css'

If you have issues, make sure that the LaravelDatatableServiceProvider class is registered in your /bootstrap/providers.php

The main class here is DatatableController

Use it

Override the panel id value-the current/default value is 'datatablePanel'. After 
setting the id, do not forget to edit your panel styling in 
public/vendor/laravel-datatable/css/datatable.css. Go in there & edit the styling 
for 'datatablePanel'. The reason for allowing you to set an id attribute on the panel 
that wraps around the table is to allow you use CSS to customise the look and behaviour 
of the table, and, or JS to manipulate the table dynamically. If you do assign a 
panelId, do not forget to go into the CSS stylesheet in your public directory and 
change the panelId from the default one 'datatablePanel' to the one you have added.

Do not forget to use the config file 'config/laravel-datatable.php' to enter base 
settings for your data table. See the 'Your datatable configurations' below.

You would display the generated table ('usersTable') in your view blade file like so:

Description of the arguments passed to DatatableController

A word on the date_field config setting for the orderBy clause

-You must only use a datetime/timestamp type for this field, and not a 'date' format  
    because the package code expects a time segment in the date string given.

How to handle actions on the action (manage) buttons

-When you indicate that you want the table records to be clickable (config file), the system 
 will create anchor links for the individual records and automatically send the record ids 
 with these links. All you then have to do create the routes to match those paths.

-Also, when you add buttons, the system will add anchor links to them, adding in the record 
 ids as well. Here is an example of how you would create a route to handle deletion of a 
 record:

Generating a table from more than one model (powered by Eloquent joins)

This is also possible, but it has some limitations (see 'Limitation to joining models' below). 
Let us assume you want a table of records from two tables 'blog' and 'blog_comments', and you 
are going to link them based on a foreign key for example, where 
blog.id = blog_comments.blog_id. 

The steps are very similar except for one extra method that you need to call: 'setJoinData()'

Here is how you would do it. First of all, instantiate the DatatableController class exactly 
as you would when generating a table for a single model. Pass it the model name of the 
main (parent) table of the join relationship. A parent table is the table whose primary key 
is used as foreign keys in other (child) tables. In our case the main table would be 'blog'.
Also pass in the optional arguments like dataRoute, fields, config exactly as you would do
for a single model. 

Next, call the setJoinData() method and pass it three arrays eg: 

Once you have passed the main model you want to the constructor, eg:

    $dataTableClass = new DatatableController('Blog');

    You can now make a join on it like so:
        -call the method $dataTableClass->setJoinData()
            -pass it as first argument as an array of join strings where the 
                first element is the (child) table to join on the main table eg: 

                ["'blog_comments', 'blog.id', '=', 'blog_comments.blog_id'"];

                Here the 'blog_comments' table will be joined on the main 'blog' table
                on the condition that blog.id is equal to blog_comments.blog_id. 

            -The optional second argument is a select string in case you only want 
                specific fields-leave it blank to select all fields from all tables joined. 
                Use aliases to avoid column name conflicts, or use a wildcard on a table 
                name eg 'tableName.*' to select all fields on that table eg:

                "'blog.id as post_id', 'blog.blog_title', 'blog.blog_article', 
                'blog.blog_author as author', 'blog_comments.blog_comments as comment', 
                'blog_comments.blog_comments_author as commentor'"

                Note that when it comes to joins like this, if you need the table records 
                to be clickable, when you call setJoinData(), you MUST create an alias
                of the primary key. Do it like so:

                    'blog_comments.blog_comments_id as primary_key'

                This will tell the system what the unique key of the joined records are.

            -The optional second argument is a where string which basically refers to a 
                where clause if there is any eg:

                "'blog_comments.blog_comments_status', 'valid'"

The rest is the steps are exactly the same as with generating a table for a single model:
    -Optionally call the addColumn() and the addFieldButton() methods.
    -Then finally genrate the table and render the table view file like so:

    $panelId = 'blogPanel'; 
    $blogCommentsTable = $dataTableClass->getTable($panelId);
    return view('admin.contactMessages', ['contactMessagesTable' => $blogCommentsTable]);

Feel free to call $dataTableClass->setJoinData(...) multiple times to join more tables to 
the main table.

Here is an example of a model join

Limitation to joining models

The only set back to joining models with this DatatableController class is that the 
generated table fields of the main table are going to be the only fields you can 
do sorting on. The fields from the joined (children) tables will only serve as
display data.

Your datatable configurations

Once you have run the command

The config file will be generated for you and placed in 

    'config/laravel-datatable.php'

There are 4 fields that you should have separate entries per model for because 
they are unique to every model's records 
The config settings here must be prefixed with the model names in all lowercase. 

    '..._panelId'       => '',
    '..._heading'       => '',
    '..._date_field'    => '',
    '..._orderBy'       => '',

These should be prefixed here with the model names-in all lowercase. Here is an
example entry for these fields for 'blog' and 'blog_comments' tables.

There are four other fields that are generic and will apply to all your data 
tables, so you do not have to set them for every model.

Customising the look of your table

It is up to you to style the generated table as you wish.
The table is wrapped in a panel with the id of: 'datatablePanel' or any id you 
specified for it when you called getTable($panelId)

The table element itself also has an id generated from the model name like so 
id='modelname_table'

You may use the panelId and table id attributes to customise the styling of the 
table.

All versions of laravel-datatable with dependencies

PHP Build Version
Package Version
No informations.
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 gustocoder/laravel-datatable contains the following files

Loading the files please wait ....