Conditions | 5 |
Paths | 6 |
Total Lines | 17 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php namespace Afrittella\BackProject\Traits; |
||
19 | public function addAttachment($data = [], $user_id = null) |
||
20 | { |
||
21 | if (empty($user_id)) { |
||
22 | if ($user = Auth::user()) { |
||
23 | $user_id = $user->id; |
||
|
|||
24 | } |
||
25 | } |
||
26 | |||
27 | // If morphOne attachment, and one attachment is present, we must delete it |
||
28 | if (!$this->multi and $this->hasAttachments()) { |
||
29 | $this->deleteAttachment($this->getAttachment()); |
||
30 | } |
||
31 | |||
32 | return $this->attachments()->create(array_merge($data, ['user_id' => $user_id])); |
||
33 | |||
34 | //return $attachment->save(); |
||
35 | } |
||
36 | |||
49 | } |
If you access a property on an interface, you most likely code against a concrete implementation of the interface.
Available Fixes
Adding an additional type check:
Changing the type hint: