Blank icon property if icon file is missing during store/update

This commit is contained in:
Bubka 2020-01-27 13:52:47 +01:00
parent c948bc5f24
commit f2dbf3f1e2

View File

@ -52,6 +52,28 @@ public function getIconAttribute($value)
return $value; return $value;
} }
/**
* Prevent setting a missing icon
*
* @param string $value
* @return string
*/
public function setIconAttribute($value)
{
if( !Storage::exists('public/icons/' . pathinfo($value)['basename']) ) {
$this->attributes['icon'] = '';
}
else {
$this->attributes['icon'] = $value;
}
}
/** /**
* Get the account type. * Get the account type.
* *