1 | <?php |
||
8 | trait BlameableTrait |
||
9 | { |
||
10 | /** |
||
11 | * Boot the Blameable service by attaching |
||
12 | * a new observer into the current model object. |
||
13 | * |
||
14 | * @return void |
||
15 | */ |
||
16 | public static function bootBlameableTrait() |
||
20 | |||
21 | /** |
||
22 | * Build blameable query scope. |
||
23 | * |
||
24 | * @param \Illuminate\Database\Eloquent\Builder $query |
||
25 | * @param mixed $userId |
||
26 | * @param string $key |
||
27 | * |
||
28 | * @return \Illuminate\Database\Eloquent\Builder |
||
29 | */ |
||
30 | private function buildBlameableScope(Builder $query, $userId, $key) |
||
38 | |||
39 | /** |
||
40 | * Get the user who created the record. |
||
41 | * |
||
42 | * @return \Illuminate\Database\Eloquent\Model |
||
|
|||
43 | */ |
||
44 | public function creator() |
||
51 | |||
52 | /** |
||
53 | * Get the user who updated the record for the last time. |
||
54 | * |
||
55 | * @return \Illuminate\Database\Eloquent\Model |
||
56 | */ |
||
57 | public function updater() |
||
64 | |||
65 | /** |
||
66 | * createdBy Query Scope. |
||
67 | * |
||
68 | * @param \Illuminate\Database\Eloquent\Builder $query |
||
69 | * @param mixed $userId |
||
70 | * |
||
71 | * @return \Illuminate\Database\Eloquent\Builder |
||
72 | */ |
||
73 | public function scopeCreatedBy(Builder $query, $userId) |
||
77 | |||
78 | /** |
||
79 | * updatedBy Query Scope. |
||
80 | * |
||
81 | * @param \Illuminate\Database\Eloquent\Builder $query |
||
82 | * @param mixed $userId |
||
83 | * |
||
84 | * @return \Illuminate\Database\Eloquent\Builder |
||
85 | */ |
||
86 | public function scopeUpdatedBy(Builder $query, $userId) |
||
90 | |||
91 | /** |
||
92 | * Silently update the model without firing any |
||
93 | * events. |
||
94 | * |
||
95 | * @return void |
||
96 | */ |
||
97 | public function silentUpdate() |
||
106 | |||
107 | /** |
||
108 | * Define an inverse one-to-one or many relationship. |
||
109 | * |
||
110 | * @param string $related |
||
111 | * @param string $foreignKey |
||
112 | * @param string $otherKey |
||
113 | * @param string $relation |
||
114 | * |
||
115 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
116 | */ |
||
117 | abstract public function belongsTo($related, $foreignKey = null, $otherKey = null, $relation = null); |
||
118 | |||
119 | /** |
||
120 | * Get the attributes that have been changed since last sync. |
||
121 | * |
||
122 | * @return array |
||
123 | */ |
||
124 | abstract public function getDirty(); |
||
125 | |||
126 | /** |
||
127 | * Get the primary key for the model. |
||
128 | * |
||
129 | * @return string |
||
130 | */ |
||
131 | abstract public function getKeyName(); |
||
132 | |||
133 | /** |
||
134 | * Get the value of the model's primary key. |
||
135 | * |
||
136 | * @return mixed |
||
137 | */ |
||
138 | abstract public function getKey(); |
||
139 | |||
140 | /** |
||
141 | * Get a new query builder that doesn't have any global scopes. |
||
142 | * |
||
143 | * @return \Illuminate\Database\Eloquent\Builder|static |
||
144 | */ |
||
145 | abstract public function newQueryWithoutScopes(); |
||
146 | } |
||
147 |
This check compares the return type specified in the
@return
annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.