From 996665a3ee427cad301146aad720108f8351c352 Mon Sep 17 00:00:00 2001 From: Amir Date: Sun, 4 Sep 2022 09:50:30 +0800 Subject: [PATCH 1/2] add migration filemarhun --- app/Http/Controllers/MarhunController.php | 16 ++++++++ app/Models/FileMarhun.php | 20 ++++++++++ ...2_08_30_125405_create_filemarhun_table.php | 37 +++++++++++++++++++ resources/views/marhun/marhun.blade.php | 19 +++++----- routes/web.php | 6 +-- 5 files changed, 85 insertions(+), 13 deletions(-) create mode 100644 app/Models/FileMarhun.php create mode 100644 database/migrations/2022_08_30_125405_create_filemarhun_table.php diff --git a/app/Http/Controllers/MarhunController.php b/app/Http/Controllers/MarhunController.php index 8b9a8cac..3928cbbc 100644 --- a/app/Http/Controllers/MarhunController.php +++ b/app/Http/Controllers/MarhunController.php @@ -14,6 +14,7 @@ use App\Models\JenisKarat; use App\Models\Gadai; use App\Models\Lelong; use App\Models\CawanganLelong; +use App\Models\FileMarhun; use App\Models\LelongBid; use App\Models\LelongBidMarhun; use App\Models\LelKarat; @@ -1119,5 +1120,20 @@ class MarhunController extends Controller return view('marhun.scanbarcode'); } + public function savePhotoOverallMarhun(Request $request) { + // dump($request->gambarMarhun); + $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() { + + } } diff --git a/app/Models/FileMarhun.php b/app/Models/FileMarhun.php new file mode 100644 index 00000000..85886211 --- /dev/null +++ b/app/Models/FileMarhun.php @@ -0,0 +1,20 @@ +bigIncrements('id'); + $table->unsignedBigInteger('lelongbid_id')->unsigned()->nullable(); + $table->unsignedBigInteger('lelongbidmarhun_id')->unsigned()->nullable(); + $table->string('file_type'); + $table->timestamps(); + }); + + // once the table is created use a raw query to ALTER it and add the MEDIUMBLOB + DB::statement("ALTER TABLE filemarhun ADD filename LONGBLOB"); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('filemarhun'); + } +} diff --git a/resources/views/marhun/marhun.blade.php b/resources/views/marhun/marhun.blade.php index e6473d4a..1fecce0c 100644 --- a/resources/views/marhun/marhun.blade.php +++ b/resources/views/marhun/marhun.blade.php @@ -254,24 +254,25 @@ - + + diff --git a/routes/web.php b/routes/web.php index 6086f4f5..b9a744e5 100644 --- a/routes/web.php +++ b/routes/web.php @@ -240,6 +240,8 @@ Route::group(['middleware' => ['permission:semakanmarhun','permission:kemaskinim Route::post('/tambahmarhun',['as'=>'marhun.tambahmarhun','uses'=>'MarhunController@tambahmarhun']); Route::get('/exportmarhundetails/{lelong_id}',['as'=>'marhun.exportmarhundetails','uses'=>'MarhunController@exportmarhundetails']); + //Penilai + Route::post('/savephotooverallmarhun',['as'=>'marhun.savephotooverallmarhun','uses'=>'MarhunController@savePhotoOverallMarhun']); }); //Khazanah @@ -442,10 +444,6 @@ Route::get('laporanlelfullcaw/{lelong_id}',['as'=>'reportcaw.laporanlelfullcaw', Route::get('indexbrglelpembidacaw',['as'=>'reportcaw.indexbrglelpembidacaw','uses'=>'ReportCawanganController@indexbrglelpembidacaw']); Route::get('laporanbrglelpembidacaw/{lelong_id}',['as'=>'reportcaw.laporanbrglelpembidacaw','uses'=>'ReportCawanganController@laporanbrglelpembidacaw']); - - - - }); From 71842138bf609524f3f2e3d80a7d98ac54efad01 Mon Sep 17 00:00:00 2001 From: Amir Date: Mon, 5 Sep 2022 09:09:21 +0800 Subject: [PATCH 2/2] add photo marhun --- app/Http/Controllers/MarhunController.php | 46 +++++-- app/Models/FileMarhun.php | 1 + .../2022_01_13_064027_create_file_table.php | 1 + ...2_08_30_125405_create_filemarhun_table.php | 4 +- resources/views/marhun/marhun.blade.php | 116 +++++++++++++----- routes/web.php | 3 +- 6 files changed, 124 insertions(+), 47 deletions(-) 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 @@
- +
+ Kembali +
@if ($message = Session::get('success')) -
+

{{ $message }}

@endif @@ -28,15 +30,16 @@
-
Thumbnail marhun
-
- -Tiada Data- -
-
@@ -62,7 +65,11 @@ @foreach ($marhun as $item) {{ $loop->iteration }} - + + + {{ $item->marhun }} @if($item->karat != null) @@ -245,27 +252,68 @@
-