diff --git a/app/Http/Controllers/MarhunController.php b/app/Http/Controllers/MarhunController.php index 3928cbbc..8e1880fd 100644 --- a/app/Http/Controllers/MarhunController.php +++ b/app/Http/Controllers/MarhunController.php @@ -412,8 +412,19 @@ class MarhunController extends Controller public function show($id, $lelong_id) { - $lelongbid = LelongBid::where('id','=',$id)->first(); - $marhun = LelongBidMarhun::where('lelongbid_id','=',$id)->get(); + $lelongbid = LelongBid::where('id', '=', $id)->first(); + $filemarhun = FileMarhun::where('lelongbid_id', '=', $lelongbid['id']) + ->where('photo_type', '=', '1')->first(); + if (isset($filemarhun)) { + $lelongbid->filemarhun = $filemarhun->filename; + } + $marhun = LelongBidMarhun::where('lelongbid_id', '=', $id)->get(); + foreach ($marhun as $index) { + $eachmarhun = FileMarhun::where('lelongbidmarhun_id', '=', $index['id'])->first(); + if (isset($eachmarhun)) { + $index->eachmarhun = $eachmarhun->filename; + } + } $lelkarat = LelKarat::where('lelong_id','=',$lelongbid->lelong_id)->get(); $karatall = JenisKarat::all(); $emasall = JenisEmas::all(); @@ -1120,20 +1131,29 @@ class MarhunController extends Controller return view('marhun.scanbarcode'); } - public function savePhotoOverallMarhun(Request $request) { - // dump($request->gambarMarhun); + public function addPhotoMarhun(Request $request) { $data = base64_encode($request->gambarMarhun->get()); $file_type = $request->gambarMarhun->extension(); - $addfile = new FileMarhun(); - $addfile->file_type = $file_type; - $addfile->filename = $data; - $addfile->save(); - // dd($addfile); - } - - public function savePhotoEachMarhun() { - + if ($request->photo_type == 1) { + $addfile = new FileMarhun(); + $addfile->lelongbid_id = $request->lelongbid_id; + $addfile->photo_type = 1; + $addfile->file_type = $file_type; + $addfile->filename = $data; + $addfile->save(); + } + else if ($request->photo_type == 2) { + $addfile = new FileMarhun(); + $addfile->lelongbid_id = $request->lelongbid_id; + $addfile->lelongbidmarhun_id = $request->lelongbidmarhun_id; + $addfile->photo_type = 2; + $addfile->file_type = $file_type; + $addfile->filename = $data; + $addfile->save(); + } + return redirect()->route('marhun.show', [$request->lelongbid_id, $request->lelong_id]) + ->with('success','Gambar Berjaya Di Simpan.'); } } diff --git a/app/Models/FileMarhun.php b/app/Models/FileMarhun.php index 85886211..0d543e25 100644 --- a/app/Models/FileMarhun.php +++ b/app/Models/FileMarhun.php @@ -14,6 +14,7 @@ class FileMarhun extends Model protected $fillable = [ 'lelongbid_id', 'lelongbidmarhun_id', + 'photo_type', //1-overall_marhun, 2-each_marhun 'file_type', 'filename', ]; diff --git a/database/migrations/2022_01_13_064027_create_file_table.php b/database/migrations/2022_01_13_064027_create_file_table.php index 2a575f7a..d4e9b6be 100644 --- a/database/migrations/2022_01_13_064027_create_file_table.php +++ b/database/migrations/2022_01_13_064027_create_file_table.php @@ -3,6 +3,7 @@ use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; +use Illuminate\Support\Facades\DB; class CreateFileTable extends Migration { diff --git a/database/migrations/2022_08_30_125405_create_filemarhun_table.php b/database/migrations/2022_08_30_125405_create_filemarhun_table.php index 354b7566..a7e987c1 100644 --- a/database/migrations/2022_08_30_125405_create_filemarhun_table.php +++ b/database/migrations/2022_08_30_125405_create_filemarhun_table.php @@ -3,6 +3,7 @@ use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; +use Illuminate\Support\Facades\DB; class CreateFilemarhunTable extends Migration { @@ -15,8 +16,9 @@ class CreateFilemarhunTable extends Migration { Schema::create('filemarhun', function (Blueprint $table) { $table->bigIncrements('id'); - $table->unsignedBigInteger('lelongbid_id')->unsigned()->nullable(); + $table->unsignedBigInteger('lelongbid_id')->unsigned(); $table->unsignedBigInteger('lelongbidmarhun_id')->unsigned()->nullable(); + $table->unsignedBigInteger('photo_type')->unsigned(); $table->string('file_type'); $table->timestamps(); }); diff --git a/resources/views/marhun/marhun.blade.php b/resources/views/marhun/marhun.blade.php index 1fecce0c..33df6a05 100644 --- a/resources/views/marhun/marhun.blade.php +++ b/resources/views/marhun/marhun.blade.php @@ -4,9 +4,11 @@
{{ $message }}