1 | <?php |
||||
0 ignored issues
–
show
Coding Style
introduced
by
![]() |
|||||
2 | |||||
0 ignored issues
–
show
|
|||||
3 | namespace UniSharp\Uploadable\Traits; |
||||
4 | |||||
5 | use UniSharp\Uploadable\File; |
||||
6 | use UniSharp\Uploadable\Image; |
||||
7 | use Illuminate\Database\Eloquent\Relations\MorphOne; |
||||
8 | use Illuminate\Database\Eloquent\Relations\MorphMany; |
||||
9 | |||||
10 | trait WithImages |
||||
0 ignored issues
–
show
|
|||||
11 | { |
||||
0 ignored issues
–
show
|
|||||
12 | use Helpers; |
||||
13 | |||||
14 | public static function bootWithImages(): void |
||||
0 ignored issues
–
show
|
|||||
15 | { |
||||
0 ignored issues
–
show
|
|||||
16 | static::deleted(function ($model) { |
||||
0 ignored issues
–
show
|
|||||
17 | 4 | $model->images->each(function ($image) { |
|||
0 ignored issues
–
show
|
|||||
18 | $image->delete(); |
||||
19 | 4 | }); |
|||
0 ignored issues
–
show
For multi-line function calls, the closing parenthesis should be on a new line.
If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line: someFunctionCall(
$firstArgument,
$secondArgument,
$thirdArgument
); // Closing parenthesis on a new line.
![]() |
|||||
20 | 6 | }); |
|||
0 ignored issues
–
show
For multi-line function calls, the closing parenthesis should be on a new line.
If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line: someFunctionCall(
$firstArgument,
$secondArgument,
$thirdArgument
); // Closing parenthesis on a new line.
![]() |
|||||
21 | 2 | } |
|||
0 ignored issues
–
show
|
|||||
22 | |||||
23 | 6 | public function image(): MorphOne |
|||
0 ignored issues
–
show
|
|||||
24 | { |
||||
0 ignored issues
–
show
|
|||||
25 | 6 | return $this->morphOne(Image::class, 'uploadable')->whereNull('extra')->latest('id'); |
|||
0 ignored issues
–
show
It seems like
morphOne() 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
![]() |
|||||
26 | } |
||||
0 ignored issues
–
show
|
|||||
27 | |||||
28 | 6 | public function images(): MorphMany |
|||
0 ignored issues
–
show
|
|||||
29 | { |
||||
0 ignored issues
–
show
|
|||||
30 | 6 | return $this->morphMany(Image::class, 'uploadable'); |
|||
0 ignored issues
–
show
It seems like
morphMany() 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
![]() |
|||||
31 | } |
||||
0 ignored issues
–
show
|
|||||
32 | |||||
33 | 2 | public function bindImage(File $image, $extra = null): self |
|||
0 ignored issues
–
show
|
|||||
34 | { |
||||
0 ignored issues
–
show
|
|||||
35 | 2 | return $this->bindUploadable($image, $extra); |
|||
36 | } |
||||
0 ignored issues
–
show
|
|||||
37 | } |
||||
0 ignored issues
–
show
|
|||||
38 |