Home » Laravel DataTables Server side Processing Example

Laravel DataTables Server side Processing Example

Today, We want to share with you Laravel DataTables Server side Processing Example.In this post we will show you Laravel server side processing for Datatables, hear for Implement datatables server side processing Laravel – datatables ajax we will give you demo and example for implement.In this post, we will learn about DataTables Server-side Processing in Laravel with an example.

Laravel DataTables Server side Processing Example

There are the Following The simple About Laravel DataTables Server side Processing Example Full Information With Example and source code.

As I will cover this Post with live Working example to develop laravel datatables server side pagination, so the some implement DataTables server-side in laravel for this example is following below.

Step 1: Install Laravel Application

composer create-project --prefer-dist laravel/laravel atmiya256

Step 2: Install Package

composer require yajra/laravel-datatables-oracle

config/app.php

Read Also:  Codeigniter Fullcalendar Example Tutorial From Scratch

And then you successfully install this libs DataTable package, And then open simple Laravel Path Like config/app.php file as well as Include this Laravel service provider with alias.

'providers' => [
	....
	//Include a Laravel Plugin
	Yajra\Datatables\DatatablesServiceProvider::class,

],

'aliases' => [
	....
	//Include a Laravel Plugin

	'Datatables' => 'Yajra\Datatables\Facades\Datatables',

]

config/datatables.php

php artisan vendor:publish --team=datatables

Step 3: Make demo_members_info Table

php artisan make:migration create_demo_members_info_table

database/migrations

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

//laravel datatables ajax
class CreateDemoMemberInfosTable extends Migration
{
    /**
     * Run the migrations.
     * laravel datatables ajax
     * @return void
     */
    public function up()
    {
        Schema::create('demo_members_info', function (Blueprint $table) {
            $table->increments('id');
            $table->string('title');
            $table->string('types');
            $table->string('team');
            $table->timestamps();
        });
    }


    /**
     * Reverse the migrations.
     * drop laravel datatables bootstrap
     * @return void
     */
    public function down()
    {
        Schema::drop("demo_members_info");
    }
}

run Below Commands

php artisan migrate

Step 4: Define a Laravel Route

routes/web.php

Route::get('datatable', ['uses'=>'[email protected]']);
Route::get('datatable/getmemberinfo', ['as'=>'datatable.getmemberinfo','uses'=>'[email protected]']);

Step 5: Create Controller

app/Http/Controllers/MemberInfoController.php

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Datatables;
use DB;

class MemberInfoController extends Controller
{

    public function datatable()
    {
        return view('datatable');
    }

    public function getMemberInfos()
    {
    	$members = DB::table('demo_members_info')->select('*');
        return Datatables::of($members)
            ->make(true);
    }
}

Step 6: Make a Laravel Blade View files

resources/views/datatable.blade.php

<!DOCTYPE html>
<html>
<head>
    <title>Laravel server side processing for Datatables using yajra package</title>
    <link rel="stylesheet" href="plugin/bootstrap-3.min.css">


    <link href="//cdn.datatables.net/1.10.12/css/jquery.dataTables.min.css" rel="stylesheet">
    <script src="//demo.itsolutionstuff.com/plugin/jquery.js"></script>
    <script src="//cdn.datatables.net/1.10.12/js/jquery.dataTables.min.js"></script>
</head>
<body>

<h1>Implement datatables server side processing Laravel - datatables ajax</h1>
<b>DataTables - Server-side Processing in Laravel 5.7 using Yajra</b>
<div class="container">
  <table id="members" class="pakainfo table table-hover table-condensed" style="width:100%">
    <thead>
        <tr>
            <th>Id</th>
            <th>MemberInfo</th>
            <th>Types</th>
            <th>Team</th>
        </tr>
    </thead>
  </table>
</div>


<script type="text/javascript">
$(document).ready(function() {
    oTable = $('#members').DataTable({
        "processing": true,
        "serverSide": true,
        "ajax": "{{ route('datatable.getmemberinfo') }}",
        "columns": [
            {data: 'id', name: 'id'},
            {data: 'title', name: 'title'},
            {data: 'types', name: 'types'},
            {data: 'team', name: 'team'}
        ]
    });
});
</script>
</body>
</html>

and last step to finally I am 100% successfully ready to Laravel project run DataTables Server-side Processing in Laravel Therefor run bellow simple command ro quick On terminal run:

Read Also:  Ad Rotate Text Animation Effects using jQuery

php artisan serve

and then We can open this bellow url on your any mozila, chrome or any browser:

http://localhost:8000

Angular 6 CRUD Operations Application Tutorials

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Laravel DataTables Server side Processing Example.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Read Also:  Laravel Datatables edit Column HTML Source Code render

Related FAQ

Here are some more FAQ related to this Article:

  1. Read Also:  Laravel 6 Collection Filter Method Examples
  2. Read Also:  Laravel 5.8 Datatables Server Side Processing
  3. Read Also:  Laravel 6 Global Scope Tutorial Example
  4. Read Also:  Angular 6 Forms Validation Tutorial Example From Scratch
  5. Read Also:  PHP Laravel Datatable Server Side Processing using jQuery
  6. Read Also:  jQuery Ajax File Upload images using PHP MySQLi
  7. Read Also:  Server-side processing Laravel DataTables
  8. Read Also:  Top 10 Great Cloud Storage File Sharing Services
  9. Read Also:  How to get the current page name using PHP?
  10. Read Also:  Laravel Datatable Pagination Sorting and Search server side processing

Leave a Comment

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