| Conditions | 4 |
| Paths | 4 |
| Total Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 14 | function addMediaTo(\Spatie\MediaLibrary\HasMedia $model, $collection = 'default', $input = 'file') { |
||
| 15 | if (request()->has($input)) { |
||
| 16 | $file = request()->input($input); |
||
| 17 | |||
| 18 | if (is_array($file)) { |
||
| 19 | foreach ($file as $_file) { |
||
| 20 | $model->addMedia(storage_path("tmp/{$_file}"))->toMediaCollection($collection); |
||
| 21 | } |
||
| 22 | } else { |
||
| 23 | $model->addMedia(storage_path("tmp/{$file}"))->toMediaCollection($collection); |
||
| 24 | } |
||
| 25 | } |
||
| 26 | } |
||
| 27 | } |
||
| 28 |