PHP code example of todstoychev / table-sorter

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

    

todstoychev / table-sorter example snippets


'providers' => [
    // ...
    Todstoychev\TableSorter\ServiceProvider::class,
    // ...
],

'aliases' => [
    // ...
    'TableSorter' => Todstoychev\TableSorter\TableSorter::class,
    // ...
],
 artisan vendor/publish

class MyController
{
    public function getMyAction(Request $request)
    {
        // Get parameters 
        $limit = $request->input('limit') ? $request->input('limit') : null;
        $order = $request->input('order') ? $request->input('order') : null;
        // Database column name or alias
        $param = $request->input('param') ? $request->input('param') : null;
        
        $query = MyModel::orderBy($param, $order);
        $results = $query->paginate($limit);
        
        return view('my.view', [
            'limit' => $limit,
            'order' => $order,
            'param' => $parm,
            'results' => $results
        ]);
    }
}
config/app.php