PHP code example of fusic / laravel-sortable

1. Go to this page and download the library: Download fusic/laravel-sortable 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/ */

    

fusic / laravel-sortable example snippets


$ php artisan make:sortable EmployeeSortable



namespace App\Sort;

use Sortable\Sortable;

class EmployeeSortable extends Sortable
{
    public function __construct()
    {
        $this->params = [  // write here!
            'employee_number',
            'name' => 'Employees.fullname',  // URL parameter => column name
            'birthday' => function ($builder, $query, $sortKey, $sortDirection) {
                // write custom 'order by' condition
                return $builder->orderBy('foo', 'desc');
            },
        ];
    }
}