fix: undefined behaviour in ParameterForm edit

This commit is contained in:
b1ek 2024-08-20 17:42:50 +10:00
parent 6f246afc8f
commit 821ed27b2c
Signed by: blek
GPG Key ID: 14546221E3595D0C
1 changed files with 13 additions and 2 deletions

View File

@ -55,11 +55,22 @@ class ParameterForm extends Model
if ($param->type == 2) {
if ($this->icon) {
$icon = Image::fromUploadedFile($this->icon);
// https://rent4health.com/wp-content/uploads/2020/02/Under-arm-crutches-1.png
if ($param->getAttribute('icon') !== null) {
$param->icon = $icon->id;
} else {
$param->setAttribute('icon', $icon->id);
}
}
if ($this->iconGray) {
$iconGray = Image::fromUploadedFile($this->iconGray);
if ($param->getAttribute('icon_gray') !== null) {
$param->iconGray = $iconGray->id;
} else {
$param->setAttribute('icon_gray', $iconGray->id);
}
}
$param->setAttributes([