From f2dbf3f1e2ecee4018df9ffa1a2474efbdb92d5e Mon Sep 17 00:00:00 2001 From: Bubka <858858+Bubka@users.noreply.github.com> Date: Mon, 27 Jan 2020 13:52:47 +0100 Subject: [PATCH] Blank icon property if icon file is missing during store/update --- app/TwoFAccount.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/app/TwoFAccount.php b/app/TwoFAccount.php index d041a75f..3d31d2a0 100644 --- a/app/TwoFAccount.php +++ b/app/TwoFAccount.php @@ -52,6 +52,28 @@ public function getIconAttribute($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. *