1 | <?php |
||||
2 | |||||
3 | namespace App\Traits; |
||||
4 | |||||
5 | use Illuminate\Database\Eloquent\Relations\Relation; |
||||
6 | use Illuminate\Support\Facades\Config; |
||||
7 | |||||
8 | trait CreatedBy |
||||
9 | { |
||||
10 | public static function bootCreatedBy() |
||||
11 | { |
||||
12 | self::creating(fn ($model) => $model->setCreatedBy()); |
||||
13 | } |
||||
14 | |||||
15 | public function createdBy(): Relation |
||||
16 | { |
||||
17 | $userModel = Config::get('auth.providers.users.model'); |
||||
18 | |||||
19 | return $this->belongsTo($userModel, 'created_by'); |
||||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||
20 | } |
||||
21 | |||||
22 | public static function bootUpdatedBy() |
||||
23 | { |
||||
24 | self::creating(fn ($model) => $model->setUpdatedBy()); |
||||
25 | } |
||||
26 | |||||
27 | public function UpdatedBy(): Relation |
||||
28 | { |
||||
29 | $userModel = Config::get('auth.providers.users.model'); |
||||
30 | |||||
31 | return $this->belongsTo($userModel, 'updated_by'); |
||||
32 | } |
||||
33 | |||||
34 | private function setCreatedBy($value = 1) |
||||
0 ignored issues
–
show
The parameter
$value is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. ![]() |
|||||
35 | { |
||||
36 | // if($value==''){ |
||||
37 | // if (Auth::check()) { |
||||
38 | // $this->created_by = Auth::id(); |
||||
39 | // } |
||||
40 | // }else{ |
||||
41 | $this->created_by = null; |
||||
0 ignored issues
–
show
|
|||||
42 | // } |
||||
43 | } |
||||
44 | |||||
45 | private function setUpdatedBy($value = 1) |
||||
0 ignored issues
–
show
The parameter
$value is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. ![]() |
|||||
46 | { |
||||
47 | // if($value==''){ |
||||
48 | // if (Auth::check()) { |
||||
49 | // $this->updated_by = Auth::id(); |
||||
50 | // } |
||||
51 | // }else{ |
||||
52 | $this->updated_by = null; |
||||
0 ignored issues
–
show
|
|||||
53 | // } |
||||
54 | } |
||||
55 | } |
||||
56 |