aleprosli/repository-pattern
最新稳定版本:v0.1.2
Composer 安装命令:
composer require aleprosli/repository-pattern
包简介
This is laravel package
README 文档
README
Automatic generate repo pattern with single command
Installation
composer require aleprosli/repository-pattern
Configuration
Publish the configuration file
php artisan vendor:publish --provider="Aleprosli\RepositoryPattern\RepositoryServiceProvider"
Go To
config.php
and import register Repository Service Provider
'providers' => [ Aleprosli\RepositoryPattern\RepositoryServiceProvider::class ],
Usage
The command
php artisan make:repo Model
Example
php artisan make:repo User
Go To
Providers/RepositoryServiceProvider.php
and bind interface and class you just created
<?php namespace App\Providers; use Illuminate\Support\ServiceProvider; class RepositoryServiceProvider extends ServiceProvider { public function register() { $this->app->bind('App\Repositories\UserRepositoryInterface','App\Repositories\UserRepository'); } }
And now go to
app/Http/Controllers/Usercontroller
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; use App\Repositories\UserRepositoryInterface; class UserController extends Controller { private $user; public function __construct(UserRepositoryInterface $user) { $this->user = $user; } /** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $users = $this->user->all(); dd($users); } }
THEN YOU GOOD TO GO. FEELS FREE TO CONTRIBUTE :)
统计信息
- 总下载量: 15
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 16
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-02-20