Change marhun photo storage directory structure

This commit is contained in:
afiq.hamzah
2022-11-24 15:06:12 +08:00
parent 50ca8f58bf
commit 9574386c93
+13 -10
View File
@@ -28,7 +28,10 @@ class MarhunPhotoService
$addfile->save();
}
$directory = "/{$request->lelongbid_id}/{$request->lelong_id}/{$request->photo_type}/";
$no_rujukan_sag = LelongBid::select('norujukan')->where('lelong_id', $request->lelong_id)->first()->norujukan;
$photo_type_name = $request->photo_type === '1' ? 'overall_photo' : 'by_marhun_photo';
$directory = "/{$no_rujukan_sag}/{$photo_type_name}/";
$imageExtension = $request->file('gambarMarhun')->getClientOriginalExtension();
$marhunImageFileName = "overall.{$imageExtension}";
@@ -44,16 +47,16 @@ class MarhunPhotoService
{
$deleteFile = FileMarhun::where('id', '=', $request->filemarhun_id)->first();
$lelongbid_id = $deleteFile->lelongbid_id;
$lelongbidmarhun_id = $deleteFile->lelongbidmarhun_id;
$lelong_id = $request->lelong_id;
$photo_type = $deleteFile->photo_type;
$no_rujukan_sag = LelongBid::select('norujukan')->where('lelong_id', $request->lelong_id)->first()->norujukan;
$photo_type_name = $request->photo_type === '1' ? 'overall_photo' : 'by_marhun_photo';
$directory = "/{$lelongbid_id}/{$lelong_id}/{$photo_type}/";
$directory = "/{$no_rujukan_sag}/{$photo_type_name}/";
$imageExtension = $deleteFile->file_type;
$marhunImageFileName = "overall.{$imageExtension}";
$lelongbidmarhun_id = $deleteFile->lelongbidmarhun_id;
if (!empty($request->lelongbidmarhun_id)) {
$marhunImageFileName = "$lelongbidmarhun_id.$imageExtension";
}
@@ -64,12 +67,13 @@ class MarhunPhotoService
public function show($lelong_id, $marhun)
{
$lelongbid_id = $marhun->lelongbid_id;
$lelongbidmarhun_id = $marhun->lelongbidmarhun_id;
$lelong_id = $lelong_id;
$photo_type = $marhun->photo_type;
$directory = "{$lelongbid_id}/{$lelong_id}/{$photo_type}/";
$no_rujukan_sag = LelongBid::select('norujukan')->where('lelong_id', $lelong_id)->first()->norujukan;
$photo_type_name = $marhun->photo_type === 1 ? 'overall_photo' : 'by_marhun_photo';
$directory = "/{$no_rujukan_sag}/{$photo_type_name}/";
$imageExtension = $marhun->file_type;
$marhunImageFileName = "overall.{$imageExtension}";
@@ -78,7 +82,6 @@ class MarhunPhotoService
$marhunImageFileName = "$lelongbidmarhun_id.$imageExtension";
}
$filePath = Storage::disk('marhun')->path("{$directory}${marhunImageFileName}");
header('Content-Type:' . $imageExtension);