Download the PHP package hpolthof/repository without Composer
On this page you can find all versions of the php package hpolthof/repository. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download hpolthof/repository
More information about hpolthof/repository
Files in hpolthof/repository
Package repository
Short Description A simple Repository Pattern implementation for Laravel 5
License
Informations about the package repository
Repositories for Laravel
This is a package that has a simple implementation of a repository pattern for use with Eloquent.
How to use?
Install the package with composer in your project.
Generator command
Now you can create repositories with a new generator command
This will create a new repository in a Repositories directory within the app directory.
Model Generator
This package will also extend the generator. When this generator is called with the parameter or and or a repository will also be generated.
The Repository
The repository is an empty class that extends which implements . This interface looks like:
Automatic Model Detection
The repository will try to detect the associated Eloquent model that should be used.
If the model is named {ModelName}Repository
, the model will automatically be used.
Setting the model manually
If the model cannot be detected or if you want to use another name, the $modelName
property should be set. This can be done as in the example below:
Usage in controllers
In a controller you can instantiate a repository using dependency injection. See the example below:
Disclaimer
This package is used for internal development, but published for public use. Obviously this software comes as is, and there are no warranties or whatsoever.
If you like the package it is always appreciated if you drop a message of gratitude! ;-)
The package was build by: Paul Olthof