Laravel 5.8 Datatables Server Side Processing

Today, We want to share with you Laravel 5.8 Datatables Server Side Processing.In this post we will show you Laravel server side processing for Datatables, hear for jQuery Datatables and Laravel Server-side implementation we will give you demo and example for implement.In this post, we will learn about DataTables – Server-side Processing in Laravel using Yajra with an example.

Laravel 5.8 Datatables Server Side Processing

There are the Following The simple About Laravel 5.8 Datatables Server Side Processing Full Information With Example and source code.

As I will cover this Post with live Working example to develop laravel 5.8 datatables server side processing, so the laravel datatables server side pagination for this example is following below.

Implement DataTables server-side in laravel

include Datatables CSS file






HTML table


Id Member First Name Member Last Name Information Age Action

add javascript code



create Laravel routes


Route::get('members','MemberController@members');
Route::post('allmembersList','MemberController@allmembersList');

create member model file



create Demo controller file

app/Http/Controllers/MemberController.php


'id', 
            1 =>'m_first_name',
            2 =>'m_last_name',
            3 =>'information',
            4 =>'m_age',
        );  
        $memberData = Members::count();            
        $filter_member = $memberData;
        $limit = $request->input('length');
        $start = $request->input('start');
        $order = $columns[$request->input('order.0.column')];
        $dir = $request->input('order.0.dir');
            
        if(empty($request->input('search.value')))
        {            
            $companys = Members::offset($start)
                         ->limit($limit)
                         ->orderBy($order,$dir)
                         ->get();
        }else {
            $search = $request->input('search.value'); 

            $companys =  Members::where('id','LIKE',"%{$search}%")
                            ->orWhere('m_first_name', 'LIKE',"%{$search}%")
->orWhere('m_last_name', 'LIKE',"%{$search}%")
->orWhere('m_age', 'LIKE',"%{$search}%")
                            ->offset($start)
                            ->limit($limit)
                            ->orderBy($order,$dir)
                            ->get();

            $filter_member = Members::where('id','LIKE',"%{$search}%")
                             ->orWhere('m_first_name', 'LIKE',"%{$search}%")
->orWhere('m_last_name', 'LIKE',"%{$search}%")
->orWhere('m_age', 'LIKE',"%{$search}%")
                             ->count();
        }
        $data = array();
        if(!empty($companys))
        {
            foreach ($companys as $key=>$company)
            {
                
                $submemberList['id'] = $key+1;
                $submemberList['m_first_name'] = $company->m_first_name;
                $submemberList['m_last_name'] = $company->m_last_name;
                $submemberList['m_age'] = $company->m_age;
                $submemberList['information'] = $company->information;
                $submemberList['action'] = ' 
';
                $data[] = $submemberList;
            }

        }
        $member_data = array(
        "draw"            => intval($request->input('draw')),  
        "recordsTotal"    => intval($memberData),  
        "recordsFiltered" => intval($filter_member), 
        "data"            => $data   
        );            
        echo json_encode($member_data); 
     }          
        
 
}

?>

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 Laravel 5.8 Datatables Server Side Processing.
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