https://github.com/stepovenko/eloquent-filter-sort-pagination
Simple filtering and sorting of data in Eloquent uses query parameters
https://github.com/stepovenko/eloquent-filter-sort-pagination
eloquent filter laravel sort
Last synced: about 2 months ago
JSON representation
Simple filtering and sorting of data in Eloquent uses query parameters
- Host: GitHub
- URL: https://github.com/stepovenko/eloquent-filter-sort-pagination
- Owner: stepovenko
- License: mit
- Created: 2022-01-16T19:01:01.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-03-25T08:16:15.000Z (about 3 years ago)
- Last Synced: 2025-01-24T08:31:19.495Z (3 months ago)
- Topics: eloquent, filter, laravel, sort
- Language: PHP
- Homepage:
- Size: 20.5 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Laravel eloquent Filter, Sort and Paginate
### Simple filtering and sorting of data in Eloquent uses query parameters for example
# Simple example
## `https://example.com?sort=price-desc&name=iphone`
```php
builder->where('products.name', 'LIKE', "%$term%");
}
}
```Or you can use
```php
$products = Product::filter($productFilter)->paginationFilter();$products = Product::filter($productFilter)->get();
$products = Product::filter($productFilter)->pagination();
```
Console command to create a filter
```php arisan make:filter Product```
### Additional methods and variables
```php
builder->where('category.name', 'LIKE', "%$term%");
}
}
```### internal public methods
```php
setDefaultSort('price-desc');
$perPega = $productFilter->getPerPage();
$request = $productFilter->getRequest();
$builder = $productFilter->getBuilder();
}}
```### You can change the way you sort and filter over classes
config publication
```php artisan vendor:publish --tag=filterable-and-sortable-config```