Download the PHP package thombas/revised-repository-pattern without Composer
On this page you can find all versions of the php package thombas/revised-repository-pattern. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download thombas/revised-repository-pattern
More information about thombas/revised-repository-pattern
Files in thombas/revised-repository-pattern
Package revised-repository-pattern
Short Description A package that adds a repository pattern which extends from the established models.
License MIT
Informations about the package revised-repository-pattern
Revised Repository Pattern for Laravel
Introduction
The Revised Repository Pattern is a Laravel package designed to help you organize your model-related logic without sacrificing the native elegance of Laravel's Eloquent models.
This package is perfect if you want:
✅ Cleaner, more structured model actions and queries
✅ Singleton-based repository access
✅ Full compatibility with Laravel's native models
Features
- Lightweight and non-intrusive
- Extends Laravel's Eloquent model system
- Clean repository interface via Singleton pattern
- Artisan commands for generating Actions & Queries
- Supports standalone Actions & Queries without model attachment
Installation
Getting Started
✅ Step 1 — Add the Trait to Your Model
Add the trait to any model you want to use the repository pattern with:
💡 If you have a base model, you can add it there to apply to all models.
✅ Step 2 — Accessing the Repository
You can access the repository both statically and through an instance:
Or, for general actions/queries:
✅ Step 3 — Generate Actions & Queries
By default, actions and queries will live under:
You can manually create these folders or use Artisan:
Optional:
Generate into subdirectories:
Resulting namespace:
✅ Step 4 — Writing an Action
Actions are simple classes where you define model-specific logic inside an __invoke() method:
Adding Parameters to an Action:
ℹ️ Always call
parent::__construct()when using the constructor.
Calling an Action with Parameters:
✅ Step 5 — Writing a Query
Queries let you encapsulate common SQL logic:
Query with Parameters:
✅ Model-Detached Query Example:
If your query doesn't need a model:
⚠️ Requires extending the
BaseQueryclass instead ofModelQuery.
✅ Calling a Query with Parameters:
🟣 Full Example
📜 Changelog
See the CHANGELOG for updates.
🤝 Contributing
Contributions are welcome!
See CONTRIBUTING.md for guidelines.
🔒 Security
If you find a security vulnerability, please check our Security Policy.
🏆 Credits
License
This package is open-sourced software licensed under the MIT License.
See the LICENSE file for full details.
All versions of revised-repository-pattern with dependencies
spatie/laravel-package-tools Version ^1.12
laravel/framework Version >=11.0