Download the PHP package tecnocampos/dynamic-model-filter without Composer
On this page you can find all versions of the php package tecnocampos/dynamic-model-filter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download tecnocampos/dynamic-model-filter
More information about tecnocampos/dynamic-model-filter
Files in tecnocampos/dynamic-model-filter
Package dynamic-model-filter
Short Description Apply request-based filters to Eloquent models in Laravel
License MIT
Informations about the package dynamic-model-filter
Dynamic Model Filter for Laravel
Apply dynamic filters to Eloquent models based on request data — including support for where
, whereDate
, between
, like
, and nested relation
filters. Comes with a flexible Blade form component for easy integration.
🚀 Installation
1. Require the package (for local testing)
⚙️ Setup
The package auto-registers via ServiceProvider
using Laravel's package discovery.
If you're loading views from the package, they will be available under the namespace:
dynamicfilters::
✅ Usage
1. Add the Trait to your Model
2. Apply Filters in Controller
🧠 Filter Syntax Reference
Each entry in public static array $filterRequest
uses the format:
Supported Types
Type | Description |
---|---|
text |
Basic where |
like |
where with %value% |
date |
whereDate |
between |
Two filters used for range (first , last ) |
relation |
Uses whereHas with nested filters |
multi |
Search across multiple fields |
Extra Options
Option | Usage |
---|---|
first / last |
Used with between filters |
field:column |
When input name differs from DB field |
type:text/like |
Type used inside relation or multi-search |
relation:name |
Relation path (user.address ) |
fields:field1,field2 |
Used with multi type |
source:request |
Fetch value from request() (default) |
🧩 Example: Advanced
🖼 Blade Component (Form) – Optional UI Integration
You can use the
Basic usage
- All submitted fields will persist values using request().
- The component will auto-render the correct field types (text, select, date).
UI Templates
You can define which template is used (Bootstrap or Tailwind) via config:
-
Set in .env:
- Or override in config file config/dynamic-model-filter.php:
The component will automatically load one of the following views:
- resources/views/components/bootstrap/filter-form.blade.php
- resources/views/components/tailwind/filter-form.blade.php
Dynamic behavior
- size: sets the grid column width (1–12) for Bootstrap and Tailwind layouts
- data: associative array for select
- attributes: any custom HTML attributes (multiple, readonly, etc.)
- class: additional CSS classes
📅 Date Support (pt_BR / en)
The filter handles date input in both BR (d/m/Y
) and EN (m/d/Y
) formats automatically using Carbon
and app locale.
✅ Requirements
- PHP 8.0+
- Laravel 8+
🤝 Contributing
Contributions are welcome! If you find a bug or have an idea for an improvement, feel free to open an issue or submit a pull request.
How to Contribute
- Fork this repository
-
Clone your fork:
-
Create a new branch for your changes:
-
Make your changes and commit:
-
Push to your fork:
- Open a Pull Request to the
main
branch of this repository
Please ensure your code follows Laravel conventions and includes relevant tests if applicable.
📖 License
MIT © TecnoCampos