1 | <?php |
||
9 | trait BlameableTrait |
||
10 | { |
||
11 | /** |
||
12 | * Get any of override 'blameable attributes'. |
||
13 | * |
||
14 | * @return array |
||
15 | */ |
||
16 | public function blameable() |
||
24 | |||
25 | /** |
||
26 | * Boot the Blameable service by attaching |
||
27 | * a new observer into the current model object. |
||
28 | * |
||
29 | * @return void |
||
30 | */ |
||
31 | public static function bootBlameableTrait() |
||
35 | |||
36 | /** |
||
37 | * Build blameable query scope. |
||
38 | * |
||
39 | * @param \Illuminate\Database\Eloquent\Builder $query |
||
40 | * @param mixed $userId |
||
41 | * @param string $key |
||
42 | * |
||
43 | * @return \Illuminate\Database\Eloquent\Builder |
||
44 | */ |
||
45 | private function buildBlameableScope(Builder $query, $userId, $key) |
||
53 | |||
54 | /** |
||
55 | * Get the user who created the record. |
||
56 | * |
||
57 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
58 | */ |
||
59 | public function creator() |
||
66 | |||
67 | /** |
||
68 | * Get the user who updated the record for the last time. |
||
69 | * |
||
70 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
71 | */ |
||
72 | public function updater() |
||
79 | |||
80 | /** |
||
81 | * createdBy Query Scope. |
||
82 | * |
||
83 | * @param \Illuminate\Database\Eloquent\Builder $query |
||
84 | * @param mixed $userId |
||
85 | * |
||
86 | * @return \Illuminate\Database\Eloquent\Builder |
||
87 | */ |
||
88 | public function scopeCreatedBy(Builder $query, $userId) |
||
92 | |||
93 | /** |
||
94 | * updatedBy Query Scope. |
||
95 | * |
||
96 | * @param \Illuminate\Database\Eloquent\Builder $query |
||
97 | * @param mixed $userId |
||
98 | * |
||
99 | * @return \Illuminate\Database\Eloquent\Builder |
||
100 | */ |
||
101 | public function scopeUpdatedBy(Builder $query, $userId) |
||
105 | |||
106 | /** |
||
107 | * Silently update the model without firing any |
||
108 | * events. |
||
109 | * |
||
110 | * @return int |
||
111 | */ |
||
112 | public function silentUpdate() |
||
123 | |||
124 | /** |
||
125 | * Confirm if the current model uses SoftDeletes. |
||
126 | * |
||
127 | * @return bool |
||
128 | */ |
||
129 | public function useSoftDeletes() |
||
133 | |||
134 | /** |
||
135 | * Define an inverse one-to-one or many relationship. |
||
136 | * |
||
137 | * @param string $related |
||
138 | * @param string|null $foreignKey |
||
139 | * @param string|null $otherKey |
||
140 | * @param string|null $relation |
||
141 | * |
||
142 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
143 | */ |
||
144 | abstract public function belongsTo($related, $foreignKey = null, $otherKey = null, $relation = null); |
||
145 | |||
146 | /** |
||
147 | * Get the attributes that have been changed since last sync. |
||
148 | * |
||
149 | * @return array |
||
150 | */ |
||
151 | abstract public function getDirty(); |
||
152 | |||
153 | /** |
||
154 | * Get the primary key for the model. |
||
155 | * |
||
156 | * @return string |
||
157 | */ |
||
158 | abstract public function getKeyName(); |
||
159 | |||
160 | /** |
||
161 | * Get the value of the model's primary key. |
||
162 | * |
||
163 | * @return mixed |
||
164 | */ |
||
165 | abstract public function getKey(); |
||
166 | |||
167 | /** |
||
168 | * Determine if the model or given attribute(s) have been modified. |
||
169 | * |
||
170 | * @param array|string|null $attributes |
||
171 | * |
||
172 | * @return bool |
||
173 | */ |
||
174 | abstract public function isDirty($attributes = null); |
||
175 | |||
176 | /** |
||
177 | * Get a new query builder that doesn't have any global scopes. |
||
178 | * |
||
179 | * @return \Illuminate\Database\Eloquent\Builder|static |
||
180 | */ |
||
181 | abstract public function newQueryWithoutScopes(); |
||
182 | } |
||
183 |