In this post, we are going to know about Server Side Datatable using Laravel 5. Data Table is one of the most important plugins in jQuery Library. It provides the lot of user-friendly functionalities like sort, pagination, and searches etc to handle the database data in our web pages. In laravel, we can implement this Server Side Datatable using yajra/laravel-datatables-oracle package. It provides full data table functionalities in our laravel web applications. Server Side Datatable help us to load web page faster than normal HTML table.

Step 1: Install Laravel

Here, we need new Laravel application for API passport implementation and demonstration. the following command helps to create a new application.

Step 2: Install Composer Package

In this step, we have to download and install laravel yajra/laravel-datatables-oracle package for use to generate Server Side Datatable. So just run following command to download and install package.

Step 3: Application configuration

After successfully installed the package then we should update the application config details to use the package in our application. Here we need to add providers & aliases array details with following details,

Step 4: Create Model, Controller, and Migration

Here, we want to create a migration for Products table using Laravel 5.5 php artisan command, so first fire bellow command:

Above command, help us to create Model, Controller, and Migration for Product master. In migration table file, we need to add the required no of columns details for product table like name, description, and price etc.

Then we need to go and update the Product model file in our application like fillable, primary key, product, etc. Product model files present at app/Product.php path and just update with following details in it.

Step 5: Routes Definition

In the fifth step, we want to add new routes for showing database data as a server-side data table. so just goto routes/web.php file and update the following routes to access data table operation in our application.

Step 6: Create Controller with Methods

On this step, we want to make a new controller for Server Side Datatable operations in laravel application. After creating a controller file we need to define a methods and handling function in it.

Step 7: Blade File Defining

In the final step, we make a one blade file with Datatable and with required CSS and JS library. Following code help us to show the database data into Server Side Datatable in laravel application using yajra/laravel-datatables-oracle package.

HTML table as,

and data-table JS script as,

Now you are ready to see the demonstration of Server Side Datatable using laravel.


5 Replies to “Server Side Datatable Using Laravel 5”

  1. Hi, your demo was excellent, helps me alot. Now I have one question. I want to open a modal for edit each row data. How can I perform this? Can you help me?

  2. excellent work , i have previous problem with yajra/laravel-datatables but u make things alot easy with this tutorial , thank you.
    but about this line in the controller
    Products::query() is this and instance of builder or what as i could not find it in laravel documentation.
    so what data type should i pass to Datatable::of() method?

Leave a Reply

Your email address will not be published. Required fields are marked *