2017 © Pedro Peláez
 

library seperate-eloquent-concerns

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

image

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

  • Sunday, December 4, 2016
  • by jnwhitley
  • Repository
  • 1 Watchers
  • 0 Stars
  • 2 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

johnwhitley/separateeloquentconcerns

Automate Eloquent models to have a defined separate builder and collection per model., (*1)

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., (*2)

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., (*3)

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"., (*4)

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., (*5)

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

  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:, (*7)

  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., (*8)

The Versions

04/12 2016

dev-master

9999999-dev

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

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by John Whitley

04/12 2016

v0.0.1

0.0.1.0

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

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by John Whitley