thantzin-soe/laravel-repository-generator

1.0.0 2023-07-13 05:15 UTC

This package is auto-updated.

Last update: 2024-04-13 07:01:25 UTC


README

Latest Version on Packagist GitHub Tests Action Status Total Downloads

You can generate laravel repository class and interface using php artisan make:repository Category/CategoryRepository --model=Category.It will generate CategoryRepository class and CategoryRepositoryInterface inside the app/Repositories/Category folder.This package is developed based on the Spatie Laravel Package Skeleton.

Installation

You can install the package via composer:

composer require thantzin-soe/laravel-repository-generator

Usage

After installing via composer,you can generate scaffolding by running

php artisan make:repository Category/CategoryRepository --model=Category

You can add your bindings to your AppServiceProvider or you can a create a new service provider with php artisan make:provider RepositoryServiceProvider(don't forget to add it in the providers array inside of config\app.php) and add the bindings in the register() method, here is the example.

namespace App\Providers; 

use Illuminate\Support\ServiceProvider;
use App\Repositories\Category\CategoryRepositoryInterface;
use App\Repositories\Category\CategoryRepository;

/** 
* Class RepositoryServiceProvider 
* @package App\Providers 
*/ 
class RepositoryServiceProvider extends ServiceProvider 
{ 
   /** 
 * Register services. 
 * 
 * @return void 
 */ 
   public function register() 
   { 
       $this->app->bind(CategoryRepositoryInterface::class, CategoryRepository::class);
   }
}

Testing

composer test

Contributing

Any contributions are welcome.