| Conditions | 4 |
| Paths | 3 |
| Total Lines | 21 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 4.0119 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 51 | 1 | public function updateImage(string $key = 'image'): ?string |
|
| 52 | { |
||
| 53 | 1 | if (!$this->hasFile($key)) { |
|
| 54 | return null; |
||
| 55 | } |
||
| 56 | |||
| 57 | /** @var \App\Models\Denomination $model */ |
||
| 58 | 1 | $model = $this->route('denomination'); |
|
| 59 | |||
| 60 | 1 | if ($model->getRawOriginal('image') && $this->hasFile($key)) { |
|
| 61 | 1 | Storage::delete(Denomination::IMAGE_PATH . '/' . $model->getRawOriginal('image')); |
|
|
|
|||
| 62 | } |
||
| 63 | |||
| 64 | 1 | $file = $this->file($key); |
|
| 65 | |||
| 66 | 1 | $file->storeAs( |
|
| 67 | 1 | Denomination::IMAGE_PATH, |
|
| 68 | 1 | $filename = ($this->input('value') . '.' . $file->getClientOriginalExtension()) |
|
| 69 | ); |
||
| 70 | |||
| 71 | 1 | return $filename; |
|
| 72 | } |
||
| 74 |