nda666 / laravel-repository-pattern
Simple repository pattern for laravel project
1.1.1
2024-08-03 03:15 UTC
Requires
- php: >=7.2
- haydenpierce/class-finder: ^0.4.3
- illuminate/console: ^5.0|^6.0|^7.0|^8.0|^9.0|^10|^11
Requires (Dev)
- orchestra/testbench: ^3.0 || ^4.0 || ^5.0 || ^6.24
- phpstan/phpstan: ^0.12.14 || ^1.0.0
- phpunit/phpunit: ^7.4 || ^8.0 || ^9.0
- squizlabs/php_codesniffer: ^3.7
This package is auto-updated.
Last update: 2025-03-31 04:41:35 UTC
README
It's a simple repository file generator.
Laravel without auto-discovery:
If you don't use auto-discovery, add the ServiceProvider to the providers array in config/app.php
LaravelRepositoryPattern\Providers\RepositoryPatternProvider::class
to publish the config file:
php artisan vendor:publish --provider="LaravelRepositoryPattern\Providers\RepositoryPatternProvider"
How To:
php artisan make:repository User
Will generate UserRepository.php and UserInterface.php file
Example
Example using generated repo in controller
<?php namespace App\Http\Controllers; use App\Repositories\UserRepository; class HomeController extends Controller { protected UserRepository $user; public function __construct(UserRepository $user) { $this->user = $user; } public function index() { return $this->user->getAll(); } }