|
1 | 1 | # Database Repository
|
2 | 2 |
|
3 |
| -## Install |
| 3 | +## Installation |
| 4 | +Use following command to add this package to composer development requirement. |
4 | 5 | ```bash
|
5 |
| -composer require nanvaie/database-repository |
| 6 | +composer require nanvaie/database-repository --dev |
| 7 | +``` |
| 8 | + |
| 9 | +### Setup for Laravel |
| 10 | +Navigate to `app.php` in `config` folder and add following line in 'provider' section: |
| 11 | +```php |
| 12 | +Nanvaie\DatabaseRepository\DatabaseRepositoryServiceProvider::class |
| 13 | +``` |
| 14 | + |
| 15 | +### Setup for Lumen |
| 16 | +Navigate to `app.php` in `bootstrap` folder and add following line after config registrations: |
| 17 | +```php |
| 18 | +$this->register->config('') |
| 19 | +``` |
| 20 | + |
| 21 | +Note: Make sure to run `composer dump-autoload` after these changes. |
| 22 | + |
| 23 | +## Usage |
| 24 | +List of artisan commands: |
| 25 | + |
| 26 | +| Command | Inputs | Options | Description | |
| 27 | +|-------------------------------------|-------------|------------|-----------------------------------| |
| 28 | +| `command:make-entity` | table_name | -f, -d, -k | Create new Entity | |
| 29 | +| `command:make-factory` | table_name | -f, -d | Create new Factory | |
| 30 | +| `command:make-resource` | table_name | -f, -d, -k | Create new Resource | |
| 31 | +| `command:make-interface-repository` | table_name | -f, -d, -k | Create new Repository Interface | |
| 32 | +| `command:make-repository` | table_name | -f, -d | Create new Base Repository | |
| 33 | +| `command:make-mysql-repository` | table_name | -f, -d, -k | Create new MySql Repository class | |
| 34 | +| `command:make-redis-repository` | table_name | -f, -d, -k | Create new Redis Repository class | |
| 35 | +| `command:make-all-repository` | table_names | -f, -d, -k | Run all of the above commands | |
| 36 | + |
| 37 | +Example 1. Create new Entity for a table named 'users'. |
| 38 | +```bash |
| 39 | +php artisan command:make-entity users |
| 40 | +``` |
| 41 | + |
| 42 | +Example 2. Create all necessary classes for two tables named 'users' and 'customers' with enabled foreign key option. |
| 43 | +```bash |
| 44 | +php artisan command:make-all-repository users,customers |
6 | 45 | ```
|
0 commit comments