Last active
April 9, 2019 09:02
-
-
Save renalpha/1505c6c278b17a04fde6344fdfa16fe4 to your computer and use it in GitHub Desktop.
Dedicated builder object
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| use Illuminate\Database\Eloquent\Builder; | |
| use Illuminate\Database\Eloquent\Model; | |
| class Team extends Model | |
| { | |
| public function newEloquentBuilder(Builder $builder) | |
| { | |
| return new TeamBuilder($builder); | |
| } | |
| public function scopeWherePrivate(Builder $builder) | |
| { | |
| $builder->where('is_public', '=', false); | |
| return $this; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| use Illuminate\Database\Eloquent\Builder; | |
| class TeamBuilder extends Builder | |
| { | |
| public function whereActive() | |
| { | |
| $this->where('is_active', '=', true); | |
| return $this; | |
| } | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage: