kingdarkness/k-repository

generator repository laravel 5.*

1.0.2 2017-12-02 02:54 UTC

This package is auto-updated.

Last update: 2024-10-29 04:59:15 UTC


README

generator repository laravel 5.*

Install

$ composer require kingdarkness/k-repository

Edit your AppServiceProvider to add the following to the register method:

$this->app->register(\KRepository\KRepositoryServiceProvider::class);
if (!empty(config('kproviders'))) {
    foreach (config('kproviders') as $provider )
    {
        $this->app->register( $provider );
    }
}

Then execute the command:

$ php artisan vendor:publish  --provider="KRepository\KRepositoryServiceProvider"

Edit config/krepository.php to your needs.

Example config

return [
    'path' => 'King',
    'files' => [
        'model' => '{name}',
        'interface' => '{name}Repository',
        'data_mapper' => 'Db{name}Repository'
    ],
    'parent' => [
        // data mapper parent class configs
        'data_mapper' => [
            'config' => true,
            'class_name' => 'BaseRepository',
            'namespace' => 'Darkness\King'
        ],
        'model' => [
            'config' => true,
            'class_name' => 'Entity',
            'namespace' => 'Darkness\King'
        ]
    ]
];

To create a simple repository:

$ php artisan make:repository User

To create a repository with migration:

$ php artisan make:repository User --migration=true

The repository will generator in app/King/Users

The migration in database/migrations

The ServiceProvider in app/Providers

The repository will automatic register ServiceProvider in configs/kproviders.php