承接 kyle-noland/laravel-base-repository 相关项目开发

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

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

kyle-noland/laravel-base-repository

Composer 安装命令:

composer require kyle-noland/laravel-base-repository

包简介

A flexible Laravel repository pattern foundation for working with Eloquent ORM

README 文档

README

A flexible Laravel repository pattern foundation for working with Eloquent ORM.

The goal of this package is to provide a foundation for building Laravel Eloquent repositories while still allowing you to create basic queries on the fly.

Installation

Install this package through Compposer. Edit your project's composer.json file to require kyle-noland/laravel-base-repository

"require": {
    "kyle-noland/laravel-base-repository": "dev-master"
}

Update Composer from the Terminal

composer update

Add the Service Provider to your app/config/app.php file

'KyleNoland\LaravelBaseRepository\LaravelBaseRepositoryServiceProvider'

Usage

Extend the BaseRepository class and implement your own custom repository logic:

<?php namespace MyProject\Repositories;

use KyleNoland\LaravelBaseRepository\BaseRepository;
use MyProject\Interfaces\CompanyRepositoryInterface;
use MyProject\Models\Company;

class CompanyRepository extends BaseRepository implements CompanyRepositoryInterface {

	public function __construct(Company $model)
	{
		$this->model = $model;
	}
	
	// Add your repository methods here

}

The BaseRepository class provides basic COUNT, SELECT, INSERT, UPDATE, DELETE, WHERE, WHERE IN clauses and the ability to eager load related models.

Counting All Models

$count = $this->companyRepo->count();

Counting a Subset of Models

$count = $this->companyRepo->where('is_active', true)->count();

Selecting Models

$allCompanies = $this->companyRepo->all();
$activeCompanies = $this->companyRepo->where('is_active', true)->get();
$activeCopmaniesInTexas = $this->companyRepo->where('is_active', true)->where('state', 'TX')->get();

统计信息

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

GitHub 信息

  • Stars: 14
  • Watchers: 3
  • Forks: 9
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2014-12-21