- Folder Structure
- Code Samples
- Other Properties
The Repository classes are an implementation of the Repository Design Pattern.
Their major roles are separating the business logic from the data (or the data access Task).
Repositories save and retrieves Models to/from the underlying storage mechanism.
The Repository is used to separate the logic that retrieves the data and maps it to a Model, from the business logic that acts on the Model.
Every Model SHOULD have a Repository.
A Model SHOULD always get accessed through its Repository. (Never accessed directly).
All Repositories MUST extend from
App\Ship\Parents\Repositories\Repository. Extending from this class will give you access to methods like (
updateand much more).
Repository name should be same as it's model name (model:
If a Repository belongs to a Model whose name is not equal to its Container name, then the Repository implement
model()method like this.
model() method must be implemented when the model has different name than the container.
To enable query parameters (
?search=text,...) in your API you need to set the property
$fieldSearchable on the Repository class, to instruct the querying on your model. More details.
Apiato uses the
l5-repository package, to provide a lot of powerful features to the repository class.
To learn more about all the properties you can use, visit the
andersao/l5-repository package documentation.