PHP code example of rogercbe / table-sorter

1. Go to this page and download the library: Download rogercbe/table-sorter 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/ */

    

rogercbe / table-sorter example snippets


Rogercbe\TableSorter\TableSorterServiceProvider::class,

use Rogercbe\TableSorter\Sortable;

class User extends Authenticatable
{
	...
	use Sortable;
	...
}

use App\User;

class UsersController extends Controller
{
	public function index()
    {
    	...
        $users = User::sortable()->get()
        ...
    }
}

$users = User::withCount('posts')->sortable()->paginate();

use Rogercbe\TableSorter\Sortable;

class User extends Authenticatable
{
    use Sortable;
    ...
    protected $tableHeaders = [
        'name' => [
        	'title' => 'User Name'
        ],
        'email' => [
        	'class' => ['my-class', 'another-class']
        ],
        'created_at' => [
			'sortable' => 'false',
			'class' => 'one-class'
        ]
    ];
    ...
}

...
	public function index()
    {
    	...
        $users = User::sortable()
            ->sortPaginate();
        ...
    }
...
sh
php artisan vendor:publish