| Conditions | 5 |
| Paths | 5 |
| Total Lines | 17 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 19 | protected function saveFiles($model) |
||
| 20 | { |
||
| 21 | if (! in_array(StorageTrait::class, class_uses($model))) { |
||
| 22 | throw new InvalidArgumentException('The model you used does not use the Storage trait'); |
||
| 23 | } |
||
| 24 | |||
| 25 | try { |
||
| 26 | foreach ($model->images as $image) { |
||
| 27 | $imageFiles = $this->getImages($model->filesDir(), $image->name, $model->getImageDimensions()); |
||
| 28 | |||
| 29 | foreach ($imageFiles as $imageFile) { |
||
| 30 | Storage::disk('s3')->put(Str::of($imageFile)->after('public/'), fopen($imageFile, 'r+'), 'public'); |
||
|
|
|||
| 31 | } |
||
| 32 | } |
||
| 33 | $this->deleteFiles($model); |
||
| 34 | } catch (\Exception $e) { |
||
| 35 | Log::error($e->getMessage()); |
||
| 36 | } |
||
| 39 |