optimize and make rewritable your project with the repository pattern
mtkh73/repo-handler is a Laravel package for optimize and make rewritable your project with the repository pattern.
It currently has 3 GitHub stars and 17 downloads on Packagist (latest version v1.2.0).
Install it with composer require mtkh73/repo-handler.
Discover more Laravel packages by mtkh73
or browse all Laravel packages to compare alternatives.
Last updated
The Repository Pattern is one of the most popular patterns to create an enterprise level application. It restricts us to work directly with the data in the application and creates new layers for database operations, business logic, and the application’s UI. using the Repository Pattern has many advantages:
php artisan make:repository ModelName
After installing this package, a command will be added on your artisan command with make:repository name. with this command you can create a repository class for your model classes.
After running this command if the model exists, a directory called Repository creates in your app directory.to use your repository class you can inject it in any controller that you want. after that you can easily use all of the features in your repository class.
php artisan make:repository Models\User
In this example, you can see a method with setFilters name!
you can apply your any eloquent filters on your query.but where is these filters??
You can create your filters with this command:php artisan make:filter With'
After creating the filter, the structure of this class like this :
The implementation of your filter must be in the handle method! the args variable includes the value that you set on the setFilters method!
Be careful after creating the filters, you have to set filters on the repository config file.
In the repositories directory, there are 4 things!
Be careful If you want using your repository class with their contracts you have to bind them together on the RepositoryServiceProvider class!
The RepositoryPattern-handler is open-sourced software licensed under the MIT license.