thantzin-soe / laravel-repository-generator
Generate laravel repositories
Requires
- php: ^8.1
- illuminate/contracts: ^10.0
- spatie/laravel-package-tools: ^1.14.0
Requires (Dev)
- laravel/pint: ^1.0
- nunomaduro/collision: ^7.9
- orchestra/testbench: ^8.0
- pestphp/pest: ^2.0
- pestphp/pest-plugin-arch: ^2.0
- pestphp/pest-plugin-laravel: ^2.0
README
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.