From 412c77ae9ca3b118a0ebd8724aee2e479185913a Mon Sep 17 00:00:00 2001 From: "afiq.hamzah" Date: Tue, 29 Nov 2022 16:47:13 +0800 Subject: [PATCH] Add exception handler when extension not available when storing marhun photo --- app/Services/MarhunPhotoService.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/Services/MarhunPhotoService.php b/app/Services/MarhunPhotoService.php index 08340e99..1cdac2a8 100644 --- a/app/Services/MarhunPhotoService.php +++ b/app/Services/MarhunPhotoService.php @@ -6,6 +6,7 @@ use Illuminate\Http\Request; use Illuminate\Support\Facades\Storage; use App\Models\FileMarhun; use App\Models\LelongBid; +use Exception; class MarhunPhotoService { @@ -14,7 +15,12 @@ class MarhunPhotoService { - $file_type = $request->gambarMarhun->extension(); + try{ + $file_type = $request->gambarMarhun->getClientOriginalExtension(); + } catch(Exception $exception){ + $file_type = 'PNG'; + logger($exception); + } $addfile = new FileMarhun(); $addfile->lelongbid_id = $request->lelongbid_id;