johnwhitley/seperate-eloquent-concerns 问题修复 & 功能扩展

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

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

johnwhitley/seperate-eloquent-concerns

Composer 安装命令:

composer require johnwhitley/seperate-eloquent-concerns

包简介

Laravel eloquent has a lot in the model class, this package helps with separating the concerns away from just the model

README 文档

README

Automate Eloquent models to have a defined separate builder and collection per model.

Eloquent allows both set and individual entity methods to be defined on the model class: this is good for small projects and good to get started using Eloquent.

There are times when a model grows to an extent where separating the set (scope prefixed) function from the individual's functions (relationships, accessors, mutators, etc.) help the model stay a more manageable size. There are a number of possible solutions that would solve this; this project advocates putting what would normally be a "scope" prefixed function into a custom builder class - one custom builder per model.

This project assumes a strict namespace for models, collections and builders, so that where the model is in a directory "Model", the collection is in a sibling directory "Collection", and the eloquent builder in another directory "Builder".

Installing

composer require johnwhitley/separateeloquentconcerns

Using

There are two options when using this model extention: to enforce the existance of the custom builder or collection; or to gracefully fall back to the default builder or collection.

To force the existance of a custom builder and a custom collection, add these traits to your model:

  use \Illuminate\Database\Eloquent\SeparateConcernsTrait, \Illuminate\Database\Eloquent\EnforcedSeparateBuilderTrait, \Illuminate\Database\Eloquent\EnforcedSeparateCollectionTrait;

To allow the existance of a custom builder and a custom collection, but fall back to the default builder or collection should they be absent; add these traits to your model:

  use \Illuminate\Database\Eloquent\SeparateConcernsTrait, \Illuminate\Database\Eloquent\OptionalSeparateBuilderTrait, \Illuminate\Database\Eloquent\OptionalSeparateCollectionTrait;

You may choose to use optional collection and enforced builder; or vise versa.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2016-12-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固