承接 contracts/repositories 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

contracts/repositories

Composer 安装命令:

composer require contracts/repositories

包简介

This package creates interfaces and repositories with resources and is capable of creating a model if it doesn't exist.

README 文档

README

To Install.

    composer require contracts/repositories dev-master

Create a new service provider and add it to the list of providers.

    php artisan  make:provider RepositoryServiceProvider

Bind the repository and interface in the register function.

    $models = array(
        'CustomModel',
        'CustomModel2',
        'CustomModel3'
    );

    foreach ($models as $model) {
        $this->app->bind("App\Contracts\\{$model}RepositoryInterface", "App\Repositories\\{$model}Repository");
    }

add the new service provider to the providers array in the config/app.php file.

// ...other declared providers
App\Providers\RepositoryServiceProvider::class,

To create a repository and interface.

    php artisan make:repo Product

Or if you want to create a repository and interface along with resources.

    php artisan make:repo Product -r

It requires your permission to create a model if it doesn't exist.

    Product Model not found! Do you want to create?  [don't do it.]:
    [0] don't do it.
    [1] do it.
    > 1

    Model [/var/www/html/my_repo_project/app/Models/Product.php] created successfully.
    Interface [/var/www/html/my_repo_project/app/Contracts/ProductRepositoryInterface.php] created successfully.
    Repository [/var/www/html/my_repo_project/app/Repositories/ProductRepositories.php] created successfully.

Finally,

    use App\Contracts\ProductRepositoryInterface;


    class HomeController extends Controller
    {
        protected ProductRepositoryInterface $productRepository;
        public function __construct(ProductRepositoryInterface $productRepository)
        {
            $this->productRepository = $productRepository;
        }

        public function index()
        {
            $post  =  $this->productRepository->all();

            //code
        }
    }

统计信息

  • 总下载量: 20
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-01-29

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固