Conditions | 3 |
Paths | 2 |
Total Lines | 11 |
Code Lines | 5 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php namespace Afrittella\BackProject\Traits; |
||
9 | public function addAttachment($data = []) |
||
10 | { |
||
11 | // If morphOne attachment, and one attachment is present, we must delete it |
||
12 | if (!$this->multi and $this->hasAttachments()) { |
||
13 | $this->deleteAttachment($this->getAttachment()); |
||
14 | } |
||
15 | |||
16 | $attachment = $this->attachments()->create($data); |
||
17 | |||
18 | return $attachment->save(); |
||
19 | } |
||
20 | |||
33 | } |
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: