1 | <?php |
||||
2 | |||||
3 | namespace Sqits\UserStamps\Concerns; |
||||
4 | |||||
5 | use Sqits\UserStamps\Observers\UserStampObserver; |
||||
6 | |||||
7 | trait HasUserStamps |
||||
8 | { |
||||
9 | /** |
||||
10 | * Bootstrap the trait. |
||||
11 | * |
||||
12 | * @return void |
||||
13 | */ |
||||
14 | public static function bootHasUserStamps() |
||||
15 | { |
||||
16 | static::observe(UserStampObserver::class); |
||||
17 | } |
||||
18 | |||||
19 | /** |
||||
20 | * Get the user that created the model. |
||||
21 | * |
||||
22 | * @return Illuminate\Database\Eloquent\Relations\BelongsTo |
||||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||
23 | */ |
||||
24 | public function author() |
||||
25 | { |
||||
26 | return $this->belongsTo( |
||||
0 ignored issues
–
show
It seems like
belongsTo() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
27 | config('userstamps.users_model'), |
||||
28 | config('userstamps.created_by_column'), |
||||
29 | config('userstamps.users_table_column_id_name') |
||||
30 | ); |
||||
31 | } |
||||
32 | |||||
33 | /** |
||||
34 | * Get the user that edited the model. |
||||
35 | * |
||||
36 | * @return Illuminate\Database\Eloquent\Relations\BelongsTo |
||||
37 | */ |
||||
38 | public function editor() |
||||
39 | { |
||||
40 | return $this->belongsTo( |
||||
41 | config('userstamps.users_model'), |
||||
42 | config('userstamps.updated_by_column'), |
||||
43 | config('userstamps.users_table_column_id_name') |
||||
44 | ); |
||||
45 | } |
||||
46 | |||||
47 | /** |
||||
48 | * Get the user that deleted the model. |
||||
49 | * |
||||
50 | * @return Illuminate\Database\Eloquent\Relations\BelongsTo |
||||
51 | */ |
||||
52 | public function destroyer() |
||||
53 | { |
||||
54 | return $this->belongsTo( |
||||
55 | config('userstamps.users_model'), |
||||
56 | config('userstamps.deleted_by_column'), |
||||
57 | config('userstamps.users_table_column_id_name') |
||||
58 | ); |
||||
59 | } |
||||
60 | |||||
61 | /** |
||||
62 | * Has the model loaded the SoftDeletes trait. |
||||
63 | * |
||||
64 | * @return bool |
||||
65 | */ |
||||
66 | public function usingSoftDeletes() |
||||
67 | { |
||||
68 | return $usingSoftDeletes = in_array( |
||||
0 ignored issues
–
show
|
|||||
69 | 'Illuminate\Database\Eloquent\SoftDeletes', |
||||
70 | class_uses_recursive( |
||||
71 | get_called_class() |
||||
72 | ) |
||||
73 | ); |
||||
74 | } |
||||
75 | } |
||||
76 |