| Conditions | 3 |
| Paths | 3 |
| Total Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | public function thumbnail($type, $attribute = 'image') |
||
| 16 | { |
||
| 17 | // Return empty string if the field not found |
||
| 18 | if (!isset($this->attributes[$attribute])) { |
||
|
|
|||
| 19 | return ''; |
||
| 20 | } |
||
| 21 | |||
| 22 | // We take image from posts field |
||
| 23 | $image = $this->attributes[$attribute]; |
||
| 24 | |||
| 25 | $thumbnail = $this->getThumbnail($image, $type); |
||
| 26 | |||
| 27 | return \Illuminate\Support\Facades\Storage::disk(config('admin.upload.disk'))->exists($thumbnail) ? $thumbnail : $image; |
||
| 28 | } |
||
| 29 | |||
| 50 |
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: