PHP Laravel 6 DataTables Tutorial

Today, We want to share with you PHP Laravel 6 DataTables Tutorial.In this post we will show you laravel 5.5 datatables tutorial, hear for yajra datatables laravel package we will give you demo and example for implement.In this post, we will learn about yajra/laravel-datatables-html with an example.

PHP Laravel 6 DataTables Tutorial

There are the Following The simple About datatables server side processing in laravel using yajra, Full Information With Example and source code.

As I will cover this Post with live Working example to develop Datatable Server Side Processing with PHP Laravel 6, so the DataTables Server-side Processing with Laravel 6 and MySQL is used for this example is following below.

Step 1: Installing Laravel 6

Install and setup Laravel 6 Web Application


//Install and setup Laravel Project
composer create-project laravel/laravel worldwideweb --prefer-dist


//2.rename the file to .env (Configuration)
mv .env.example .env


//3.env
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=worldwideweb
DB_USERNAME=root
DB_PASSWORD=worldwideweb@34896565ds

Laravel Datatable Pagination Sorting and Search server side processing

Step 2: Laravel 6 model and migration

create a language model and migration

php artisan make:model Language -m

#database/migrations/2022_09_11_895623_create_languages_table.php

public function up()
{
    Schema::create('languages', function (Blueprint $table) {
        $table->bigIncrements('id');
        $table->string('name');
        $table->string('slug');
        $table->timestamps();
    });
}
php artisan migrate

Step 3: Added Fake / dummy data

php artisan make:factory LanguageFactory

database/factories/LanguageFactory.php

define(Language::class, function (Faker $faker) {
    return [
        'name' => $faker->sentence,
        'slug' => $faker->slug(6)
    ];
});

Step 4: Install Laravel 6 datatables

composer require yajra/laravel-datatables-oracle

config/app.php

'providers' => [
    ...
    Yajra\Datatables\DatatablesServiceProvider::class,
]

//aliases
'aliases' => [
    ...
    'Datatables' => Yajra\Datatables\Facades\Datatables::class,
]

command to publish the config file

php artisan vendor:publish --provider="Yajra\DataTables\DataTablesServiceProvider"

Step 5: Setting up Blade File && view files

resources/views/layouts/master.blade.php



    
        
        
        
        Laravel 6 Servser side DataTables Tutorial - tamilrokers

        
        

        
    
    
        
@yield('content')
@stack('scripts')

run this command using terminal

php artisan make:controller WorldWideWebController

Step 6: Create a Laravel 6 Controller

app/Http/Controllers/WorldWideWebController.php

make(true);
    }
}

resources/views/index.blade.php

@extends('layouts.master')

@section('content')
    
Id Name Slug Created At Updated At
@stop @push('scripts') @endpush

Step 7: Laravel 6 Define a routes

routes/web.php

Route::get('language', 'WorldWideWebController@index');
Route::get('get-language-data', 'WorldWideWebController@languageData')->name('datatables.language')
Web Programming Tutorials Example with Demo

Read :

Summary

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

I hope you get an idea about Server side DataTable in PHP Laravel 6,MySQL and Ajax.
I would like to have feedback on my infinityknow.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.

Leave a Comment