Conditions | 3 |
Paths | 2 |
Total Lines | 13 |
Code Lines | 5 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php namespace Afrittella\BackProject\Traits; |
||
19 | public function addAttachment($data = []) |
||
20 | { |
||
21 | $user = Auth::user(); |
||
22 | |||
23 | // If morphOne attachment, and one attachment is present, we must delete it |
||
24 | if (!$this->multi and $this->hasAttachments()) { |
||
25 | $this->deleteAttachment($this->getAttachment()); |
||
26 | } |
||
27 | |||
28 | return $this->attachments()->create(array_merge($data, ['user_id' => $user->id])); |
||
29 | |||
30 | //return $attachment->save(); |
||
31 | } |
||
32 | |||
45 | } |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: