1<?php
2
3// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the GNU Affero General Public License v3.0.
4// See the LICENCE file in the repository root for full licence text.
5
6namespace App\Scopes;
7
8use Illuminate\Database\Eloquent\Builder;
9use Illuminate\Database\Eloquent\Model;
10use Illuminate\Database\Eloquent\Scope;
11
12class MacroableModelScope implements Scope
13{
14 public function apply(Builder $builder, Model $model)
15 {
16 // heh
17 }
18
19 public function extend($builder)
20 {
21 $model = $builder->getModel();
22
23 foreach ($model->getMacros() as $macro) {
24 $fname = 'macro'.ucfirst($macro);
25 $builder->macro($macro, $model->$fname());
26 }
27 }
28}