KingDarkness / k-repository by KingDarkness

generator repository laravel 5.*
1,039
3
1
Package Data
Maintainer Username: KingDarkness
Maintainer Contact: nguyentranhoan13@gmail.com (Nguyễn Trần Hoàn)
Package Create Date: 2017-03-24
Package Last Update: 2017-12-02
Language: PHP
License: MIT
Last Refreshed: 2024-12-22 03:05:42
Package Statistics
Total Downloads: 1,039
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 3
Total Watchers: 1
Total Forks: 0
Total Open Issues: 0

k-repository

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