PHP code example of team383 / data-table-laravel

1. Go to this page and download the library: Download team383/data-table-laravel library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

team383 / data-table-laravel example snippets


    public function sortFullName(Builder $query, string $direction): Builder
    {
        return $query->orderBy('last_name', $direction)->orderBy('first_name', $direction);
    }

    public function searchFullName(Builder $query, string $search_term): Builder
    {
        return $query->whereRaw('CONCAT(first_name, " ", last_name) LIKE ?', ["%$search_term%"]);
    }

    public function filterStatus(Builder $query, string $statuses): Builder
    {
        return $query->whereIn('status', explode(',', $statuses));
    }