Download the PHP package bigpaulie/repository without Composer
On this page you can find all versions of the php package bigpaulie/repository. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download bigpaulie/repository
More information about bigpaulie/repository
Files in bigpaulie/repository
Package repository
Short Description An implementation of the repository patter for Laravel Framework
License MIT
Homepage https://github.com/bigpaulie/repository
Informations about the package repository
Repository
A repository pattern implementation for Laravel Framework
Installation
Via Composer
Publish the configuration file
Compatibility
package version | laravel version |
---|---|
2.x | 6.9 or newer |
1.x | 5.x |
Usage
A repository class is any class that extends bigpaulie\repository\AbstractRepository
The general rule of thumb is that your repository should have the same name as your model by with a suffix of "Repository".
Let's say we have the following case, we have a model named Person, than the repository class should be named PersonRepository
Generating repositories using artisan commands
You can generate a repository for your model using the provided artisan command
The above command will generate a repository class called PersonRepository.
Find
Find a specific resource by it's ID
Get all
Get all results for this resource
Create
Create's a new resource and return the database object, if your model doesn't allow mass assigning of attributes, use false
as the second parameter.
Update
Update a specific resource by it's ID, you can also pass a model instance as a second parameter.
Delete
Delete a specific resource by it's ID, you can also force delete by passing true
as the second parameter.
Using helper function
You can use the helper function by providing the FQDN of a repository or a model.
If a repository exists for a given model, an instance of the repository is returned otherwise an abstract repository is returned allowing you to preform all the builtin CRUD functionality.
The Person model has a PersonRepository
The Dog model doesn't have a repository
Learn more
Check out our wiki
Change log
Please see the changelog for more information on what has changed recently.
Testing
Contributing
Please see contributing.md for details and a todolist.
Security
If you discover any security related issues, please email author email instead of using the issue tracker.
Credits
License
license. Please see the license file for more information.