1 | <?php |
||
9 | class SoftEnablingScope implements Scope |
||
10 | { |
||
11 | /** |
||
12 | * All of the extensions to be added to the builder. |
||
13 | * |
||
14 | * @var array |
||
15 | */ |
||
16 | protected $extensions = ['Enable', 'Disable', 'WithDisabled', 'WithoutDisabled', 'OnlyDisabled']; |
||
17 | |||
18 | /** |
||
19 | * Apply the scope to a given Eloquent query builder. |
||
20 | * |
||
21 | * @param \Illuminate\Database\Eloquent\Builder $builder |
||
22 | * @param \Illuminate\Database\Eloquent\Model $model |
||
23 | * @return void |
||
24 | */ |
||
25 | 24 | public function apply(Builder $builder, Model $model) |
|
29 | |||
30 | /** |
||
31 | * Extend the query builder with the needed functions. |
||
32 | * |
||
33 | * @param \Illuminate\Database\Eloquent\Builder $builder |
||
34 | * @return void |
||
35 | */ |
||
36 | 29 | public function extend(Builder $builder) |
|
42 | |||
43 | /** |
||
44 | * Add the enable extension to the builder. |
||
45 | * |
||
46 | * @param \Illuminate\Database\Eloquent\Builder $builder |
||
47 | * @return void |
||
48 | */ |
||
49 | 29 | protected function addEnable(Builder $builder) |
|
57 | |||
58 | /** |
||
59 | * Add the disable extension to the builder. |
||
60 | * |
||
61 | * @param \Illuminate\Database\Eloquent\Builder $builder |
||
62 | * @return void |
||
63 | */ |
||
64 | 29 | protected function addDisable(Builder $builder) |
|
72 | |||
73 | /** |
||
74 | * Add the with-disabled extension to the builder. |
||
75 | * |
||
76 | * @param \Illuminate\Database\Eloquent\Builder $builder |
||
77 | * @return void |
||
78 | */ |
||
79 | 29 | protected function addWithDisabled(Builder $builder) |
|
85 | |||
86 | /** |
||
87 | * Add the without-disabled extension to the builder. |
||
88 | * |
||
89 | * @param \Illuminate\Database\Eloquent\Builder $builder |
||
90 | * @return void |
||
91 | */ |
||
92 | 29 | protected function addWithoutDisabled(Builder $builder) |
|
105 | |||
106 | /** |
||
107 | * Add the only-disabled extension to the builder. |
||
108 | * |
||
109 | * @param \Illuminate\Database\Eloquent\Builder $builder |
||
110 | * @return void |
||
111 | */ |
||
112 | protected function addOnlyDisabled(Builder $builder) |
||
125 | } |
||
126 |