├── .gitignore ├── composer.json ├── readme.md └── src ├── Commands └── RepositoryPattern.php ├── Facades └── RepositoryPattern.php ├── RepositoryServiceProvider.php ├── Services └── RepositoryService.php └── stubs ├── Repository.stub ├── RepositoryInterface.stub └── RepositoryServiceProvider.stub /.gitignore: -------------------------------------------------------------------------------- 1 | vendor -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aleprosli/repository-pattern", 3 | "description": "This is laravel package", 4 | "type": "library", 5 | "license": "MIT", 6 | "autoload": { 7 | "psr-4": { 8 | "Aleprosli\\RepositoryPattern\\": "src/" 9 | } 10 | }, 11 | "authors": [ 12 | { 13 | "name": "aleprosli", 14 | "email": "aliff.rosli96@gmail.com" 15 | } 16 | ], 17 | "minimum-stability": "dev", 18 | "extra": { 19 | "laravel": { 20 | "providers": [ 21 | "Aleprosli\\RepositoryPattern\\RepositoryServiceProvider" 22 | ] 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # Repository Package 2 | 3 | Automatic generate repo pattern with single command 4 | 5 | ## Installation 6 | ``` 7 | composer require aleprosli/repository-pattern 8 | ``` 9 | 10 | ## Configuration 11 | Publish the configuration file 12 | 13 | ``` 14 | php artisan vendor:publish --provider="Aleprosli\RepositoryPattern\RepositoryServiceProvider" 15 | ``` 16 | 17 | ## Go To 18 | ```config.php``` 19 | and import register Repository Service Provider 20 | 21 | ```php 22 | 'providers' => [ 23 | Aleprosli\RepositoryPattern\RepositoryServiceProvider::class 24 | ], 25 | 26 | ``` 27 | 28 | ## Usage 29 | 30 | The command 31 | 32 | ``` 33 | php artisan make:repo Model 34 | ``` 35 | ## Example 36 | 37 | ``` 38 | php artisan make:repo User 39 | ``` 40 | 41 | ## Go To 42 | ```Providers/RepositoryServiceProvider.php``` 43 | and bind interface and class you just created 44 | 45 | ```php 46 | app->bind('App\Repositories\UserRepositoryInterface','App\Repositories\UserRepository'); 58 | } 59 | } 60 | 61 | ``` 62 | ## And now go to 63 | ```app/Http/Controllers/Usercontroller``` 64 | 65 | ```php 66 | user = $user; 80 | } 81 | 82 | /** 83 | * Display a listing of the resource. 84 | * 85 | * @return \Illuminate\Http\Response 86 | */ 87 | public function index() 88 | { 89 | $users = $this->user->all(); 90 | 91 | dd($users); 92 | } 93 | } 94 | ``` 95 | 96 | ## THEN YOU GOOD TO GO. FEELS FREE TO CONTRIBUTE :) 97 | -------------------------------------------------------------------------------- /src/Commands/RepositoryPattern.php: -------------------------------------------------------------------------------- 1 | argument('name'); 42 | 43 | RepositoryService::create($name); 44 | 45 | $this->info("Successfully create repository for model ". $name); 46 | } 47 | } -------------------------------------------------------------------------------- /src/Facades/RepositoryPattern.php: -------------------------------------------------------------------------------- 1 | loadViewsFrom(__DIR__.'/../stubs', 'RepositoryPattern'); 13 | $this->publishes([ 14 | __DIR__.'/stubs' => base_path('/App/stubs')]); 15 | } 16 | 17 | public function register() 18 | { 19 | $this->commands([ 20 | RepositoryPattern::class, 21 | ]); 22 | } 23 | } -------------------------------------------------------------------------------- /src/Services/RepositoryService.php: -------------------------------------------------------------------------------- 1 | update($data); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/stubs/RepositoryInterface.stub: -------------------------------------------------------------------------------- 1 | app->bind( 13 | /* 14 | * Register your Repository classes and interface here 15 | **/ 16 | ); 17 | } 18 | } 19 | --------------------------------------------------------------------------------