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() |
||
119 | |||
120 | /** |
||
121 | * Confirm if the current model uses SoftDeletes. |
||
122 | * |
||
123 | * @return bool |
||
124 | */ |
||
125 | public function useSoftDeletes() |
||
129 | |||
130 | /** |
||
131 | * Define an inverse one-to-one or many relationship. |
||
132 | * |
||
133 | * @param string $related |
||
134 | * @param string|null $foreignKey |
||
135 | * @param string|null $otherKey |
||
136 | * @param string|null $relation |
||
137 | * |
||
138 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
139 | */ |
||
140 | abstract public function belongsTo($related, $foreignKey = null, $otherKey = null, $relation = null); |
||
141 | |||
142 | /** |
||
143 | * Get the attributes that have been changed since last sync. |
||
144 | * |
||
145 | * @return array |
||
146 | */ |
||
147 | abstract public function getDirty(); |
||
148 | |||
149 | /** |
||
150 | * Get the primary key for the model. |
||
151 | * |
||
152 | * @return string |
||
153 | */ |
||
154 | abstract public function getKeyName(); |
||
155 | |||
156 | /** |
||
157 | * Get the value of the model's primary key. |
||
158 | * |
||
159 | * @return mixed |
||
160 | */ |
||
161 | abstract public function getKey(); |
||
162 | |||
163 | /** |
||
164 | * Get a new query builder that doesn't have any global scopes. |
||
165 | * |
||
166 | * @return \Illuminate\Database\Eloquent\Builder|static |
||
167 | */ |
||
168 | abstract public function newQueryWithoutScopes(); |
||
169 | } |
||
170 |