PHPackages                             doncadavona/eloquenturl - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. doncadavona/eloquenturl

ActiveLibrary[Database &amp; ORM](/categories/database)

doncadavona/eloquenturl
=======================

Search and filter Laravel Eloquent models by query parameters with ease.

v0.4.37(3mo ago)1741[3 issues](https://github.com/doncadavona/eloquenturl/issues)MITPHP

Since May 3Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/doncadavona/eloquenturl)[ Packagist](https://packagist.org/packages/doncadavona/eloquenturl)[ Docs](https://github.com/doncadavona/eloquenturl)[ RSS](/packages/doncadavona-eloquenturl/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (3)Versions (10)Used By (0)

Eloquenturl
===========

[](#eloquenturl)

[![Latest Version on Packagist](https://camo.githubusercontent.com/d9acf8038948a252dea5a7a14a826b8ced5b4c10cabfe270dce2c7d8439ec1c5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f646f6e63616461766f6e612f656c6f7175656e7475726c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/doncadavona/eloquenturl)[![Total Downloads](https://camo.githubusercontent.com/366dfa7d6751aac12faa0668ac1ff3f5a10e63fcbe753b2a76c8fbc6bd49d8f4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f646f6e63616461766f6e612f656c6f7175656e7475726c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/doncadavona/eloquenturl)[![Build Status](https://camo.githubusercontent.com/9d1e343a7254e41da452bb188215e13b360cab7e039b2dfbd9cf2779626b8daa/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f646f6e63616461766f6e612f656c6f7175656e7475726c2f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/doncadavona/eloquenturl)[![StyleCI](https://camo.githubusercontent.com/cb13a877afd1dbe223c631789c3f922d3ace958fdb334a9cce9b26afefbc2ebd/68747470733a2f2f7374796c6563692e696f2f7265706f732f31323334353637382f736869656c64)](https://styleci.io/repos/12345678)

Eloquenturl automatically adds search and filtering for your Eloquent models using [query strings](https://en.wikipedia.org/wiki/Query_string).

Eloquenturl respects the `$fillable` and `$hidden` attributes of your Eloquent models to make sensible defaults, providing zero-configuration usage. For example:

```
return \Doncadavona\Eloquenturl\Eloquenturl::eloquenturled(\App\Models\User::class, $request);
```

By just passing the model and the request, the model is made searchable and filterable without you having to manage which attributes are queryable and without writing complex logic and database queries.

*Eloquenturl is fast* because it is built and executed as a single database query.

Read [Eloquenturl: A Laravel Package to Simplify or Eliminate Query Building for URL Parameters](https://dev.to/doncadavona/eloquenturl-a-laravel-package-to-simplify-or-eliminate-query-building-for-url-parameters-2iem).

Table of Contents
-----------------

[](#table-of-contents)

- [I. Installation](#i-installation)
- [II. Usage](#ii-usage)
- [III. Query Parameters](#iii-query-parameters)
- [IV. Change Log](#iv-change-log)
- [V. Testing](#v-change-log)
- [VI. Contributing](#vi-contributing)
- [VII. Security](#vii-security)
- [VIII. Credits](#viii-credits)
- [IX. License](#ix-license)

I. Installation
---------------

[](#i-installation)

Install using Composer:

```
composer require doncadavona/eloquenturl
```

II. Usage
---------

[](#ii-usage)

**Eloquenturl::eloquenturled()**

Use `Eloquenturl::eloquenturled()` to quickly build and execute the database query based on the request query parameters. It returns the paginated entries of the given Eloquent model, based on the URL parameters and the model's `$fillable` and `$hidden` attributes. Just pass the model and the request:

```
$users = \Doncadavona\Eloquenturl\Eloquenturl::eloquenturled(User::class, request());
```

**Eloquenturl::eloquenturl()**

Use `Eloquenturl::eloquenturl()` when you need to add additional queries, such as eager-loading, or any other database queries available in [Laravel Query Builder](http://laravel.com/docs/queries).

Here is an example `UsersController` with several examples.

```
