Fix saving marhun photo file to correct directory

This commit is contained in:
afiq.hamzah
2022-11-27 15:15:44 +08:00
parent 2c6b80c345
commit 578338b05d
3 changed files with 9 additions and 10 deletions
+3 -2
View File
@@ -517,6 +517,7 @@ class MarhunController extends Controller
{
$lelongbid = LelongBid::where('id', '=', $id)->first();
$norujukan_sag = $lelongbid->norujukan;
$filemarhun = FileMarhun::where('lelongbid_id', '=', $lelongbid['id'])
->where('photo_type', '=', '1')
->first();
@@ -537,7 +538,7 @@ class MarhunController extends Controller
foreach ($marhun as $index) {
$eachmarhun = FileMarhun::where('lelongbidmarhun_id', '=', $index['id'])->first();
if (isset($eachmarhun)) {
$index->eachmarhun_filename = route('marhun.showphotomarhun', ['lelong_id' => $lelong_id, 'filemarhun_id' => $eachmarhun]);
$index->eachmarhun_filename = route('marhun.showphotomarhun', ['norujukan_sag' => $norujukan_sag, 'filemarhun_id' => $eachmarhun]);
$index->eachmarhun_id = $eachmarhun->id;
}
@@ -2258,7 +2259,7 @@ class MarhunController extends Controller
public function showPhotoMarhun(Request $request)
{
$marhun = FileMarhun::where('id', '=', $request->filemarhun_id)->first();
return $this->marhunPhotoService->show($request->lelong_id, $marhun);
return $this->marhunPhotoService->show($request->norujukan_sag, $marhun);
}
+4 -6
View File
@@ -28,7 +28,7 @@ class MarhunPhotoService
$addfile->save();
}
$no_rujukan_sag = LelongBid::select('norujukan')->where('lelong_id', $request->lelong_id)->first()->norujukan;
$no_rujukan_sag = LelongBid::select('norujukan')->where('id', $request->lelongbid_id)->first()->norujukan;
$photo_type_name = $request->photo_type === '1' ? 'overall_photo' : 'by_marhun_photo';
$directory = "/{$no_rujukan_sag}/{$photo_type_name}/";
@@ -47,7 +47,7 @@ class MarhunPhotoService
{
$deleteFile = FileMarhun::where('id', '=', $request->filemarhun_id)->first();
$no_rujukan_sag = LelongBid::select('norujukan')->where('lelong_id', $request->lelong_id)->first()->norujukan;
$no_rujukan_sag = LelongBid::select('norujukan')->where('id', $request->lelongbid_id)->first()->norujukan;
$photo_type_name = $request->photo_type === '1' ? 'overall_photo' : 'by_marhun_photo';
$directory = "/{$no_rujukan_sag}/{$photo_type_name}/";
@@ -65,15 +65,13 @@ class MarhunPhotoService
$deleteFile->delete();
}
public function show($lelong_id, $marhun)
public function show($norujukan_sag, $marhun)
{
$lelongbidmarhun_id = $marhun->lelongbidmarhun_id;
$lelong_id = $lelong_id;
$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}/";
$directory = "/{$norujukan_sag}/{$photo_type_name}/";
$imageExtension = $marhun->file_type;
$marhunImageFileName = "overall.{$imageExtension}";
+2 -2
View File
@@ -66,7 +66,7 @@
<div class="card-body" style="align-self: center; justify-content: center;">
@if ($lelongbid['filemarhun_filename'] != null)
<button type="button" data-toggle="modal" onclick="kesulurahanMarhunData(this)" data-lelongid="{{$lelongbid['lelong_id']}}" data-lelongbidid="{{$lelongbid['id']}}" data-fileid="{{ $lelongbid['filemarhun_id'] }}" data-target="#modaloverallphoto">
<img src="{{ route('marhun.showphotomarhun', ['lelong_id' => $lelongbid['lelong_id'], 'filemarhun_id' => $lelongbid['filemarhun_id']]) }}" width="100%">
<img src="{{ route('marhun.showphotomarhun', ['norujukan_sag' => $lelongbid['norujukan'], 'filemarhun_id' => $lelongbid['filemarhun_id']]) }}" width="100%">
</button>
@else
<p>Tiada Data</p>
@@ -426,7 +426,7 @@
@else
<div class="row mt-5 justify-content-center">
@php
$imageLink = route('marhun.showphotomarhun', ['lelong_id' => $lelongbid['lelong_id'], 'filemarhun_id' => $lelongbid['filemarhun_id']]);
$imageLink = route('marhun.showphotomarhun', ['norujukan_sag' => $lelongbid['norujukan'], 'filemarhun_id' => $lelongbid['filemarhun_id']]);
@endphp
<a href="{{ $imageLink }}" target="_blank" class="btn m-2 btn-warning">Lihat gambar</a>
<button data-dismiss="modal" onclick="updatePhoto(1)" type="button"