An open API service indexing awesome lists of open source software.

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

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```