Download the PHP package tes/laravel-relafilter without Composer
On this page you can find all versions of the php package tes/laravel-relafilter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download tes/laravel-relafilter
More information about tes/laravel-relafilter
Files in tes/laravel-relafilter
Package laravel-relafilter
Short Description A lightweight Laravel package to filter model data through nested relationships using a simple input structure.
License MIT
Informations about the package laravel-relafilter
Laravel Relafilter
Laravel Relafilter is a lightweight and expressive filtering package for Laravel models. It allows you to filter using deeply nested relationships without writing complex query logic.
⚠️ This package is not a replacement for Laravel's Query Builder. Instead, it's a lightweight and simpler alternative for specific use cases — especially useful in Livewire components or API filters.
🚀 Installation
✅ Key Features
- Simple syntax using array-based filters
- Supports nested relationships (
employee.current_company.position.name
) - Supports common query operators like
=
,like
,>
,<
,!=
- Supports
whereBetween
for date ranges - Perfect for use in Livewire or traditional controllers
🔧 Usage
🟢 In Livewire
🟡 In Controller
🔍 Supported Operators
Syntax | SQL Equivalent | Example |
---|---|---|
:like |
LIKE |
name:like => John |
:= |
= |
status:= => active |
:!= |
!= |
type:!= => admin |
:> |
> |
age:> => 30 |
:< |
< |
created_at:< => 2024-01-01 |
default | LIKE |
If no operator provided |
🧠 How It Works
The filter()
method inspects the keys of the input array, and for any nested key (e.g. company.manager.name:like
), it automatically applies the correct whereHas
or where
clause.
It also supports additional logic such as range filtering using whereBetween
, particularly for date ranges.
📅 Date Range Example
If both start
and end
values are present in the filters, it will apply a whereBetween
clause on the start_date
column:
✨ Example Filter Input (Array)
🧩 Integration
Make sure your model uses the HasRelafilter
trait:
📦 Package Status
This package is still in early development. Please report any issues or suggestions via GitHub.
📄 License
This package is open-source software licensed under the MIT license.
All versions of laravel-relafilter with dependencies
illuminate/support Version ^9.0 || ^10.0 || ^11.0
nesbot/carbon Version ^2.0