PHP code example of nemesis / laravel-filter-and-sorting

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

    

nemesis / laravel-filter-and-sorting example snippets


    class SomeModel extends Model
    {
        use FilterAndSorting;

        ...

        public function extraFields()
        {
            return ['someRelation'];
        }

        ...

        public function someRelation()
        {
            return $this->hasOne(SomeRelation::class);
        }
    }

  public function index(Request $request)
  {
      return SomeModel::setFilterAndRelationsAndSort($request)->get()
  }