Download the PHP package thalles/repositories-commands without Composer
On this page you can find all versions of the php package thalles/repositories-commands. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download thalles/repositories-commands
More information about thalles/repositories-commands
Files in thalles/repositories-commands
Package repositories-commands
Short Description Artisan commands to create repositories
License MIT
Informations about the package repositories-commands
LaravelRepositories
Artisan commands to create repositories
This package provides an easy way to quickly setup and create a Repository using Unit Of Work Pattern.
- Requirements
- Installation
- Configuration
- Usage
- Default Repository Methods
- Unit Of Work methods
1. Requirements
- PHP >= 7.1.3
- laravel/framework ^5.8
2. Installation
Require the package using composer:
3. Configuration
Run the following command to create the main Repository and Interface for this repository.
Pay attention to the terminal output. You will need to copy the output and paste on register method of AppServiceProvider.
4. Usage
To create a new repository, use the following command.
The fisrt argument is the repository name. The second is the model that you want to use. If your model was not on default path, you can inform the path to file.
Exemple:
Add the repository attribute to the UnitOfWork class.
Use the UnitOfWorkInterface on your code implementation.
5. Default Repository Methods
This package makes available some methods to be used on CRUD.
-
Return an item with defined id.
-
Return all rows from database.
-
Add a new item to database.
-
Update an item in database.
-
Delete an item from database.
-
Return total of items in database.
- Format model data.
If you need to create another methods for your repository, fist register the method on the Interface, after implementing the method on Repository.
-
Interface.
- Repository.
6. Unit Of Work methods
-
Begin the database transaction.
-
Commit the transaction changes.
- Rollback the transaction changes.