Conditions | 2 |
Paths | 2 |
Total Lines | 19 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 6 |
Changes | 0 |
1 | <?php |
||
20 | public static function upload($model, $files, $encrypted = false, $admin_only = false) |
||
21 | { |
||
22 | $modelName = strtolower(class_basename($model)).'_'; |
||
23 | |||
24 | foreach ($files as $file) { |
||
25 | $data = []; |
||
26 | |||
27 | Storage::makeDirectory($modelName.$model->id); |
||
28 | |||
29 | Storage::disk('local') |
||
30 | ->put($modelName.$model->id.'/'.$file->getClientOriginalName(), self::encryptFileContents($file, $encrypted)); |
||
31 | |||
32 | $data['filename'] = $file->getClientOriginalName(); |
||
33 | $data['mime'] = $file->getClientMimeType(); |
||
34 | $data['encrypted'] = $encrypted; |
||
35 | $data['admin_only'] = $admin_only; |
||
36 | $model->attachments()->create($data); |
||
37 | } |
||
38 | } |
||
39 | |||
49 |