aleprosli/repository-pattern 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

GitHub 信息

  • Stars: 16
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-02-20

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固