https://github.com/matthewbdaly/laravel-repositories
A base repository class and interface, together with a caching decorator. Extend them for use in your own projects
https://github.com/matthewbdaly/laravel-repositories
cache caching decorator-pattern laravel php repo repository-pattern
Last synced: 7 months ago
JSON representation
A base repository class and interface, together with a caching decorator. Extend them for use in your own projects
- Host: GitHub
- URL: https://github.com/matthewbdaly/laravel-repositories
- Owner: matthewbdaly
- License: mit
- Created: 2017-11-14T17:13:33.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-06-08T09:21:11.000Z (about 7 years ago)
- Last Synced: 2024-07-22T03:02:19.516Z (11 months ago)
- Topics: cache, caching, decorator-pattern, laravel, php, repo, repository-pattern
- Language: PHP
- Size: 35.2 KB
- Stars: 12
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# laravel-repositories
[](https://travis-ci.org/matthewbdaly/laravel-repositories)
[](https://coveralls.io/github/matthewbdaly/laravel-repositories?branch=master)
A base repository class and interface, together with a caching decorator. Extend them for use in your own projects.The base interface is `Matthewbdaly\LaravelRepositories\Repositories\Interfaces\AbstractRepositoryInterface`. Your repositories should have interfaces that extend this, to facilitate type-hinting them.
This interface is implemented by both the abstract decorator `Matthewbdaly\LaravelRepositories\Repositories\Decorators\BaseDecorator` and the abstract repository `Matthewbdaly\LaravelRepositories\Repositories\Base`. Again, you should extend these classes to create your own repositories and decorators. You can then resolve these interfaces in your own service provider as follows:
```php
app->singleton('App\Repositories\Interfaces\ExampleRepositoryInterface', function () {
$baseRepo = new \App\Repositories\EloquentExampleRepository(new \App\Example);
$cachingRepo = new \App\Repositories\Decorators\ExampleDecorator($baseRepo, $this->app['cache.store']);
return $cachingRepo;
});
}
}
```Artisan tasks
-------------This package implements the following Artisan tasks to help writing boilerplate:
* `make:repository` - Makes a repository for the model passed, ie `php artisan make:repository Foo`. Pass the `--all` flag to also create the contract and decorator.
* `make:repository:contract` - Makes a contract for the model passed, ie `php artisan make:repository:contract Foo`
* `make:repository:decorator` - Makes a decorator for the model passed, ie `php artisan make:repository:decorator Foo`