Conditions | 3 |
Paths | 3 |
Total Lines | 22 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php namespace Afrittella\BackProject\Models\Observers; |
||
18 | public function creating(Attachment $attachment) |
||
19 | { |
||
20 | $file = $this->request->file('attachment'); |
||
21 | |||
22 | if (!empty($file)) { |
||
23 | $img_name = MediaManager::hashName($file->getClientOriginalExtension()); |
||
24 | if (Storage::put($img_name, file_get_contents($file->getRealPath()), ['visibility' => 'public'])) { |
||
25 | $attachment->name = $img_name; |
||
26 | $attachment->original_name = $file->getClientOriginalName(); |
||
27 | return true; |
||
28 | } else { |
||
29 | return false; |
||
30 | } |
||
31 | /*if ($path = $file->storeAs('', $img_name,['visibility' => 'public'])) { |
||
32 | $attachment->name = $path; |
||
33 | $attachment->original_name = $file->getClientOriginalName(); |
||
34 | return true; |
||
35 | } else { |
||
36 | return false; |
||
37 | }*/ |
||
38 | } |
||
39 | } |
||
40 | } |
||
41 |