Read photoMarhun in CartController

This commit is contained in:
Amir
2022-12-01 09:49:50 +08:00
parent 9050816d6f
commit 92d2460a95
5 changed files with 52 additions and 0 deletions
+5
View File
@@ -19,6 +19,8 @@ use App\Models\LelongBidMarhun;
use App\Models\LelKarat;
use App\Models\Cart;
use Carbon\Carbon;
use App\Models\FileMarhun;
class CartController extends Controller
{
@@ -78,6 +80,9 @@ class CartController extends Controller
$total_surat = 0;
foreach ($cart as $index1 => $data) {
$fileMarhun = FileMarhun::where('lelongbid_id', $data['id'])->get();
$cart[$index1]['filemarhun'] = $fileMarhun;
$total_hargabida += $data['hargabida'];
$total_berat += $data['berat'];
$total_surat += 1;
@@ -164,6 +164,8 @@ class LelongController extends Controller
->where('kodcaw', '=', $cawanganLelong->cawangan->caw_code)
->sum('total_payment');
// dd($cawanganLelong->cawangan->caw_code, $request->tarikh_lelong, $lelongDetails->masamula_lelong, $lelongDetails->masatamat_lelong, $lelongBidMaster->toArray(), $lelongbidmarhun->toArray(), floatval($paymentOnline), floatval($paymentTunai));
$exportData = Http::withOptions(['verify' => config('app.api_verify')])->post(
config('app.api_url') . 'exportLelong',
[
@@ -19,6 +19,7 @@ use App\Models\Resit;
use App\Models\FileResit;
use App\Models\Invoice;
use App\Models\JenisEmas;
use App\Services\MarhunPhotoService;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Validator;
@@ -345,6 +346,7 @@ class LelongMobileController extends Controller
if ($lelong) {
$lelongbid = LelongBid::where('lelong_id', $lelong['lelong_id'])
->where('caw_id', '=', $request->caw_id)
->where('status_jual', '=', 0)
->select('id', 'kodcaw')
->get();
$pluckedLelongBid = $lelongbid->pluck('id')->toArray();
@@ -377,6 +379,20 @@ class LelongMobileController extends Controller
$lelongbid['lelongbidmarhun'] = $lelongbidmarhun;
$fileMarhun = FileMarhun::where('lelongbid_id', $lelongbid['id'])->get();
// dd($fileMarhun);
// foreach ($fileMarhun as $index) {
// dd($index);
// // $eachmarhun = FileMarhun::where('lelongbidmarhun_id', '=', $index['id'])->first();
// // if (isset($eachmarhun)) {
// // $index->eachmarhun_filename = route('marhun.showphotomarhun', ['norujukan_sag' => $lelongbid['norujukan'], 'filemarhun_id' => $index->id]);
// // $test = route('marhun.showphotomarhun', ['norujukan_sag' => $lelongbid['norujukan'], 'filemarhun_id' => $index->id]);
// $marhunPhotoService = new MarhunPhotoService();
// $marhun_photo = $marhunPhotoService->get($lelongbid['norujukan'], $index);
// dd($marhun_photo);
// return $marhun_photo;
// }
// // dd($fileMarhun);
if ($fileMarhun->isNotEmpty()) {
$lelongbid['filemarhun'] = $fileMarhun;
@@ -398,6 +414,14 @@ class LelongMobileController extends Controller
}
}
public function photoMarhun(Request $request)
{
$fileMarhun = FileMarhun::find($request->filemarhun_id);
$marhunPhotoService = new MarhunPhotoService();
$marhun_photo = $marhunPhotoService->get($request->norujukan, $fileMarhun);
return base64_encode($marhun_photo);
}
public function lelongOnline()
{
$lelong = Lelong::where('sts_lelong', '=', 1)->first();
+19
View File
@@ -92,4 +92,23 @@ class MarhunPhotoService
header('Content-Disposition: inline; filename="'.basename($filePath).'"');
readfile($filePath);
}
public function get($norujukan_sag, $marhun)
{
$lelongbidmarhun_id = $marhun->lelongbidmarhun_id;
$photo_type_name = $marhun->photo_type === 1 ? 'overall_photo' : 'by_marhun_photo';
$directory = "/{$norujukan_sag}/{$photo_type_name}/";
$imageExtension = $marhun->file_type;
$marhunImageFileName = "overall.{$imageExtension}";
if (!empty($lelongbidmarhun_id)) {
$marhunImageFileName = "$lelongbidmarhun_id.$imageExtension";
}
return Storage::disk('marhun')->get("{$directory}${marhunImageFileName}");
}
}
+2
View File
@@ -59,6 +59,8 @@ Route::group(['middleware' => ['auth:sanctum']], function () {
Route::get('/lelongDetails/listSuratLelong', [LelongMobileController::class, 'listSuratLelong']);
//list lelong online
Route::get('/lelongOnline', [LelongMobileController::class, 'lelongOnline']);
//photo marhun
Route::get('/photoMarhun',[LelongMobileController::class, 'photoMarhun']);