PHPackages                             sofronz/elysia - 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. sofronz/elysia

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

sofronz/elysia
==============

A powerful, customizable query string filter package for Laravel that lets you filter, sort, and search models using query parameters — without writing repetitive query logic.

v1.0.2(1y ago)03MITPHPPHP ^7.3|^8.0

Since Apr 17Pushed 1y ago1 watchersCompare

[ Source](https://github.com/sofronz/elysia)[ Packagist](https://packagist.org/packages/sofronz/elysia)[ RSS](/packages/sofronz-elysia/feed)WikiDiscussions main Synced today

READMEChangelog (3)Dependencies (4)Versions (4)Used By (0)

Elysia 🔍✨
=========

[](#elysia-)

A powerful, customizable query string filter package for Laravel that lets you filter, sort, and search models using query parameters — without writing repetitive query logic.

🚀 Features
----------

[](#-features)

- 🔄 Sort by fields with ease
- 🔎 Search using LIKE
- 📥 Filter with IN clause
- 🎯 Supports custom query string mapping per model
- 🧩 Fully extensible and easy to integrate
- 🧼 Clean, well-structured codebase

📦 Installation
--------------

[](#-installation)

```
composer require sofronz/elysia
```

🛠️ Configuration
----------------

[](#️-configuration)

Publish the config (optional):

```
php artisan vendor:publish --provider="Sofronz\Elysia\ElysiaServiceProvider" --tag="config"
```

`config/elysia.php`:

```
return [
    'models' => [
        'user' => App\Models\User::class,
        'post' => App\Models\Post::class,
    ],
];
```

⚙️ Usage
--------

[](#️-usage)

In your controller:

```
use Sofronz\Elysia\Facades\Filter;
use App\Models\User;

public function index()
{
    $filteredUsers = Filter::model('user')->apply(User::query())->get();

    return response()->json($filteredUsers);
}
```

🔁 Custom Query Parameters
-------------------------

[](#-custom-query-parameters)

By default, the `Filter` package applies filters using query parameters such as `?field_sort=field_name`, `?field_like=value`, and `?field_in=value1,value2`. However, you can customize the query parameter names directly in your model.

#### Step 1: Add `getQueryStringMapping` Method in the Model

[](#step-1-add-getquerystringmapping-method-in-the-model)

To customize the query parameters, implement a `getQueryStringMapping` method in your model. This method should return an array where the keys are the custom query parameters, and the values are the corresponding model fields.

```
namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class YourModel extends Model
{
    /**
     * Map query string parameters to model attributes.
     *
     * @return array
     */
    public static function getQueryStringMapping(): array
    {
        return [
            'name_search' => 'name',  // custom query parameter `name_search` maps to `name` field
            'email_like' => 'email',  // custom query parameter `email_like` maps to `email` field
            'status_in' => 'status',  // custom query parameter `status_in` maps to `status` field
            'created_at_sort' => 'created_at',  // custom query parameter `created_at_sort` maps to `created_at` field
        ];
    }
}
```

In the example above, the custom query parameters are:

- `name_search` will filter by `name` field.
- `email_like` will perform a LIKE search on the `email` field.
- `status_in` will filter by `status` field using the `IN` clause.
- `created_at_sort` will sort by `created_at` field.

#### Step 2: Apply the Filters with Custom Query Parameters

[](#step-2-apply-the-filters-with-custom-query-parameters)

Now that you've defined custom query parameters in the model, you can use them directly in the request.

Example:

```
GET /your-model?name=John&email=john.doe%40example.com&status=active,inactive&created_at=-created_at
```

This will:

- Search for records where the `name` field contains "John".
- Perform a `LIKE` search on the `email` field.
- Filter records where the `status` is either "active" or "inactive".
- Sort the records by the `created_at` field in descending order.

### Available Filters

[](#available-filters)

- **Sort**: Add a custom query parameter like `?field_sort=field_name` to apply sorting.
- **LIKE**: Add a custom query parameter like `?field_like=value` to perform a LIKE search.
- **IN**: Add a custom query parameter like `?field_in=value1,value2` to filter using the `IN` clause.
- **Basic Where**: Add custom query filters by passing fields that exist in the model's `$fillable` attribute.

By using the `getQueryStringMapping` method, you can easily customize and map query parameters to any field in your model, giving you full control over how filters are applied in your application.

🙌 Shout Out
-----------

[](#-shout-out)

Special thanks to [ChatGPT](https://openai.com/chatgpt) 🤖 for assisting with the design and development of this package.

If you like my work or find it useful, you can support me through:

[![Buy Me a Coffee](https://camo.githubusercontent.com/4791c3d6f859b80d65ae116dcac997dde9ac8763321b8c9509eb1408269f8458/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4275792532306d6525323061253230636f666665652d6f72616e67653f6c6f676f3d6275792d6d652d612d636f66666565267374796c653d666f722d7468652d6261646765)](https://ko-fi.com/sofronzz)
[![Saweria](https://camo.githubusercontent.com/6fa2eace1ac31830728ba368ed692abfa68f902228fb17c9f3c5cea85d0cd385/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f536177657269612d646f6e6174652d6f72616e67653f7374796c653d666f722d7468652d6261646765)](https://saweria.co/sofronz)

👨‍💻 Author
----------

[](#‍-author)

**Sofronius Ruddy** (GitHub: [@sofronz](https://github.com/sofronz))
Copyright (c) 2025
All rights reserved.

📝 License
---------

[](#-license)

MIT © 2025 Sofronz/Elysia. All rights reserved.

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance46

Moderate activity, may be stable

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

3

Last Release

443d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/60031709?v=4)[Sofronius Ruddy](/maintainers/sofronz)[@sofronz](https://github.com/sofronz)

---

Top Contributors

[![sofronz](https://avatars.githubusercontent.com/u/60031709?v=4)](https://github.com/sofronz "sofronz (3 commits)")

---

Tags

laraveleloquentqueryfilter

###  Code Quality

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/sofronz-elysia/health.svg)

```
[![Health](https://phpackages.com/badges/sofronz-elysia/health.svg)](https://phpackages.com/packages/sofronz-elysia)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[api-platform/laravel

API Platform support for Laravel

58171.6k14](/packages/api-platform-laravel)[simplestats-io/laravel-client

Server-side analytics for Laravel that follows the full funnel from visit to registration to payment, attributed to the channel that drove it. Revenue, MRR, churn and ad-spend profit (ROAS/CAC) per channel. GDPR compliant, ad-blocker proof.

5021.9k](/packages/simplestats-io-laravel-client)[ntanduy/cloudflare-d1-database

Cloudflare D1 database driver for Laravel — full Eloquent &amp; Query Builder support.

267.8k](/packages/ntanduy-cloudflare-d1-database)[ghostcompiler/laravel-querybuilder

Reusable query builder helpers for Eloquent APIs on Laravel 10 through 13.

172.3k](/packages/ghostcompiler-laravel-querybuilder)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
