Laravel Dynamically Adding Multiple Columns in datatable server side

Also Read : first love marriage in the world

Today, We want to share with you Laravel Dynamically Adding Multiple Columns in datatable server side.In this post we will show you wordpress plugin require another plugin, hear for how make dynamic column datatable server side with laravel we will give you demo and example for implement.In this post, we will learn about Laravel Datatables – Dynamically add a column and enable searching on server side with an example.

Laravel Dynamically Adding Multiple Columns in datatable server side

There are the Following The simple About Laravel 6 DataTables – Dynamic Columns From Ajax Data Source? Full Information With Example and source code.

As I will cover this Post with live Working example to develop Implementing jquery server side datatable in laravel with dynamic table, so the how to get the dynamic column header and result from ajax call in jquery datatable, is used for this example is following below.

READ :  Laravel Insert Multiple Records

DataTables Server-side Processing in Laravel

Simple HTML table

<link rel="stylesheet" type="text/css" href=""/>
<script type="text/javascript" src=""></script>

<div class="row">
	<div class="col-md-12">
               <table class="table table-bordered" id="movies">
                           <th>Created At</th>

Simple javascript Source code

    $(document).ready(function () {
            "processing": true,
            "serverSide": true,
                     "url": "{{ url('allmovies') }}",
                     "dataType": "json",
                     "type": "POST",
                     "data":{ _token: "{{csrf_token()}}"}
            "columns": [
                { "data": "id" },
                { "data": "title" },
                { "data": "body" },
                { "data": "created_at" },
                { "data": "options" }


Define a Laravel Routes

Also Read : tamilblasters, 9kmovie, filmygod, hdhub4u, vegamovies, tamilrockers website link and 1377x proxy.


Route::post('allmovies', '[email protected]' )->name('allmovies');

Movie model



namespace App;

use Illuminate\Database\Eloquent\Model;

class Movie extends Model

Laravel define a simple Controller


public function allMovies(Request $request)
        $columns = array( 
                            0 =>'id', 
                            1 =>'title',
                            2=> 'body',
                            3=> 'created_at',
                            4=> 'id',
        $totalData = Movie::count();
        $totalFiltered = $totalData; 

        $limit = $request->input('length');
        $start = $request->input('start');
        $order = $columns[$request->input('order.0.column')];
        $dir = $request->input('order.0.dir');
            $movies = Movie::offset($start)
        else {
            $search = $request->input('search.value'); 

            $movies =  Movie::where('id','LIKE',"%{$search}%")
                            ->orWhere('title', 'LIKE',"%{$search}%")

            $totalFiltered = Movie::where('id','LIKE',"%{$search}%")
                             ->orWhere('title', 'LIKE',"%{$search}%")

        $data = array();
            foreach ($movies as $movie)
                $show =  route('',$movie->id);
                $edit =  route('movies.edit',$movie->id);

                $moviesData['id'] = $movie->id;
                $moviesData['title'] = $movie->title;
                $moviesData['body'] = substr(strip_tags($movie->body),0,50)."...";
                $moviesData['created_at'] = date('j M Y h:i a',strtotime($movie->created_at));
                $moviesData['options'] = " <a href='{$show}' title='SHOW' ><span class='glyphicon glyphicon-list'></span></a>
                                           <a href='{$edit}' title='EDIT' ><span class='glyphicon glyphicon-edit'></span></a>";
                $data[] = $moviesData;

        $json_movies_data = array(
                    "draw"            => intval($request->input('draw')),  
                    "recordsTotal"    => intval($totalData),  
                    "recordsFiltered" => intval($totalFiltered), 
                    "data"            => $data   
        echo json_encode($json_movies_data); 

Web Programming Tutorials Example with Demo

Read :

READ :  JavaScript Read XML File local Example


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

I hope you get an idea about Laravel Dynamically generated columns with addColumn method.
I would like to have feedback on my 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.