1 | <?php |
||
6 | trait ActivatableTrait |
||
7 | { |
||
8 | protected $activatedAtColumn = 'activated_at'; |
||
9 | |||
10 | /** |
||
11 | * Boot the activatable trait for the model. |
||
12 | * |
||
13 | * @return void |
||
14 | */ |
||
15 | public static function bootActivatableTrait() |
||
19 | |||
20 | // /** |
||
21 | // * Get a new query builder that includes deactivated data sets. |
||
22 | // * |
||
23 | // * @return \Illuminate\Database\Eloquent\Builder|static |
||
24 | // */ |
||
25 | // public static function withDeactivated() |
||
26 | // { |
||
27 | // return (new static)->newQueryWithoutScope(new ActivatableScope()); |
||
28 | // } |
||
29 | |||
30 | // /** |
||
31 | // * Get a new query builder that only includes deactivated data sets. |
||
32 | // * |
||
33 | // * @return \Illuminate\Database\Eloquent\Builder|static |
||
34 | // */ |
||
35 | // public static function onlyDeactivated() |
||
36 | // { |
||
37 | // $instance = new static; |
||
38 | // |
||
39 | // $column = $instance->getQualifiedActivatedAtColumn(); |
||
40 | // |
||
41 | // return $instance->newQueryWithoutScope(new ActivatableScope())->whereNotNull($column); |
||
42 | // } |
||
43 | |||
44 | /** |
||
45 | * Determine if the model instance is activated. |
||
46 | * |
||
47 | * @return bool |
||
48 | */ |
||
49 | public function activated() |
||
53 | |||
54 | /** |
||
55 | * Determine if the model instance is activated. Alias for activated(). |
||
56 | * |
||
57 | * @return bool |
||
58 | */ |
||
59 | public function isActivated() |
||
63 | |||
64 | /** |
||
65 | * Activate the given model instance. |
||
66 | * |
||
67 | * @return void |
||
68 | */ |
||
69 | public function activate() |
||
81 | |||
82 | /** |
||
83 | * Deactivate the given model instance. |
||
84 | * |
||
85 | * @return void |
||
86 | */ |
||
87 | public function deactivate() |
||
99 | |||
100 | /** |
||
101 | * Get the name of the "activated at" column. |
||
102 | * |
||
103 | * @return string |
||
104 | */ |
||
105 | public function getActivatedAtColumn() |
||
109 | |||
110 | /** |
||
111 | * Get the fully qualified "activated at" column. |
||
112 | * |
||
113 | * @return string |
||
114 | */ |
||
115 | public function getQualifiedActivatedAtColumn() |
||
119 | } |
||
120 |