Package Data | |
---|---|
Maintainer Username: | samueljtaylor |
Maintainer Contact: | sam@taylornetwork.ca (Sam Taylor) |
Package Create Date: | 2016-11-22 |
Package Last Update: | 2017-09-20 |
Language: | PHP |
License: | Unknown |
Last Refreshed: | 2025-02-09 15:09:58 |
Package Statistics | |
---|---|
Total Downloads: | 57 |
Monthly Downloads: | 1 |
Daily Downloads: | 0 |
Total Stars: | 1 |
Total Watchers: | 2 |
Total Forks: | 0 |
Total Open Issues: | 0 |
An easy and customizable to create repositories that will be automatically registered for you.
Via Composer
$ composer require taylornetwork/laravel-repository
Add the service provider to the providers array in config/app.php
'providers' => [
TaylorNetwork\LaravelRepository\RepositoryServiceProvider::class,
],
$ php artisan vendor:publish
Will add repository.php
to your config directory.
The service provider will automatically bind repositories to their contracts based on the settings in config/repository.php
By default Repositories are stored in App\Repositories\ModelName
where ModelName
is the name of the model the repository will handle.
The default naming convention used is ModelNameRepository
for the contract and EloquentModelName
for the class.
This package adds the artisan command repository:generate
to create the repository pattern based on settings in config/repository.php
To create a repository for the User
model
$ php artisan repository:generate User
Will create
- ProjectRoot
- app
- Repositories
- User
- UserRepository.php
- EloquentUser.php
If you are using a driver other than Eloquent
you can specify using the --driver
option
$ php artisan repository:generate User --driver=storage
Will create
- ProjectRoot
- app
- Repositories
- User
- UserRepository.php
- StorageUser.php
Note: If you plan on using other drivers add them to the drivers
array in config/repository.php
, the service provider will search for the class in the order of the array.
Same as repository:generate
but will only create the class, no contract.
$ php artisan repository:class User --driver=storage
Creates app/Repositories/User/StorageUser.php
Same as repository:generate
but will only create the contract, no class.
$ php artisan repository:contract User
Creates app/Repositories/User/UserRepository.php
Note: This command does not accept the --driver
option.
The MIT License (MIT). Please see License File for more information.