1. Go to this page and download the library: Download laravelwakeup/filter-sort 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/ */
use LaravelWakeUp\FilterSort\Traits\FilterTrait;
use LaravelWakeUp\FilterSort\Traits\SortTrait;
class Post extends Model
{
use FilterTrait, SortTrait;
// Optional: Restrict which fields can be filtered
protected array $allowedFilters = ['title', 'created_at', 'status', 'deleted_at'];
// Optional: Restrict which fields can be sorted
protected array $allowedSorts = ['id', 'created_at'];
}
// Sort by created_at DESC, then by id ASC
/posts?created_at_sort=desc&id_sort=asc
// Sort by status DESC, created_at DESC, and id ASC
/posts?status_sort=desc&created_at_sort=desc&id_sort=asc
// config/laravel-filter-sort.php
return [
'sort_field_suffix' => '_sort' // Change this to your preferred suffix
];
protected array $multiColumnSearch = [
'search_field' => 'search_txt', // The request parameter to use for the search term
'fields' => [
'username' => 'like',
'server' => 'eq',
// Add more fields as needed
],
];
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.