From 26730ced83396a9e670eb67d3c6a23c000fd05c6 Mon Sep 17 00:00:00 2001 From: Hafifie PKB Date: Thu, 23 Nov 2023 16:24:38 +0800 Subject: [PATCH] fix conflict, fix marhun harga, add faker in gadai and fix composer --- app/Http/Controllers/MarhunController.php | 14 +++- composer.json | 9 +-- config/database.php | 2 +- database/factories/GadaiFactory.php | 81 +++++++++++++++++++++++ database/factories/MarhunFactory.php | 32 +++++++++ database/seeds/GadaiSeeder.php | 26 ++++++++ tinker/fakerGadai.php | 18 +++++ 7 files changed, 171 insertions(+), 11 deletions(-) create mode 100644 database/factories/GadaiFactory.php create mode 100644 database/factories/MarhunFactory.php create mode 100644 database/seeds/GadaiSeeder.php create mode 100644 tinker/fakerGadai.php diff --git a/app/Http/Controllers/MarhunController.php b/app/Http/Controllers/MarhunController.php index 87c4b82..3d1fa5d 100644 --- a/app/Http/Controllers/MarhunController.php +++ b/app/Http/Controllers/MarhunController.php @@ -63,7 +63,17 @@ class MarhunController extends Controller $harga = HargaEmas::on('mysql7')->where('karat',$request->karat)->first(); - $nilai_marhun = $request->berat_emas * $harga['harga']; + $hargaemas = $harga['harga']; + if(isset($request->jenisAT)){ + if($request->jenisAT == 'hargalama'){ + $hargaemas = $request->harga; + // $nilai_marhun = $request->berat_emas * $request->harga; + }else $hargaemas = $harga['harga']; + // $nilai_marhun = $request->berat_emas * $harga['harga']; + }else $hargaemas = $harga['harga']; + + $nilai_marhun = $request->berat_emas * $hargaemas; + $cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first(); $marhun = Marhun::on($cawangan['mysql'])->create([ @@ -75,7 +85,7 @@ class MarhunController extends Controller 'nota' => $request->nota, 'karat' => $request->karat, 'berat' => $request->berat_emas, - 'harga' => $harga['harga'], + 'harga' => $hargaemas, 'n_marhun' => $nilai_marhun ]); diff --git a/composer.json b/composer.json index 392ab97..2c8071f 100644 --- a/composer.json +++ b/composer.json @@ -1,11 +1,7 @@ { "name": "laravel/lumen", "description": "The Laravel Lumen Framework.", - "keywords": [ - "framework", - "laravel", - "lumen" - ], + "keywords": ["framework", "laravel", "lumen"], "license": "MIT", "type": "project", "require": { @@ -21,9 +17,6 @@ "phpunit/phpunit": "^8.5" }, "autoload": { - "files": [ - "app/helpers.php" - ], "classmap": [ "database/seeds", "database/factories" diff --git a/config/database.php b/config/database.php index 3d82ab2..ece90e4 100644 --- a/config/database.php +++ b/config/database.php @@ -2,7 +2,7 @@ return [ - 'default' => 'mysql', + 'default' => 'mysql7', 'migrations' => 'migrations', 'connections' => [ 'lelong' => [ diff --git a/database/factories/GadaiFactory.php b/database/factories/GadaiFactory.php new file mode 100644 index 0000000..de17d3b --- /dev/null +++ b/database/factories/GadaiFactory.php @@ -0,0 +1,81 @@ +faker = $faker; + } + + public function create() + { + static $number = 1; + + return [ + 'kodcaw' => 'KB2', + 'norujukan' => ($number > 9) ? 'KB2231123-00' . $number : 'KB2231123-000' . $number , + 'nopelanggan' => 'M03-00009968', + 'nokp' => '630411035213', + 't_gadai' => '2023-11-23', + 'masa' => '13:46:57', + 'sirig' => $number++, + 'nilaimarhun' => 3000.09, + 'berat' => 10.17, + 'pinjaman' => 2300, + 'telahbayar' => 0.00, + 'upahtelahbyr' => 0.00, + 'cajtelahbyr' => null, + 'ansuran' => null, + 'ansupah' => null, + 'kadarupah' => null, + 'tempoh' => 0.5, + 't_lelong' => null, + 't_hapus' => null, + 'sttebus' => '', + 'terima' => 1, + 'cetak' => 1, + 'tncek' => null, + 'nocek' => null, + 'bkcode' => null, + 'teller' => 'NORLY BINTI DERAMAN', + 'pelulus' => null, + 'cancelid' => null, + 'canceltime' => null, + 'f_lulus' => null, + 'tag' => null, + 'jbg' => 0.5, + 'bakipjm' => 2300, + 'bakiupah' => 39.1, + 'upahdibayar' => 0.00, + 'marhun' => '1 R/L,', + 'taglel' => null, + 't_update' => '2023-11-23', + 't_matang' => '2024-06-24', + 't_matang1' => '2024-06-24', + 'penilai' => 'MOHD KHALID ABDUL RAHMAN', + 'tagserah' => 1, + 'namapelulus' => '', + 'percentpinj' => 80, + 'namateller' => 'NORLY BINTI DERAMAN', + 'jumtebus' => 0.00, + 'upahnotis' => 0.00, + 'tagpalsu' => 0, + 'historygadaian' => '', + 'tagcetak' => 1, + 'lel1stop' => 0, + 'tebus' => null, + 'bakihargajualan' => 2769.2, + 'hargajualan' => 2769.2, + 'upah12' => 120, + 'tagkomuditi' => 0, + 'tempohbayar' => 0, + 'lelong_tawarruq' => 0, + 'semakbarcode' => 'Lulus' + ]; + } + +} \ No newline at end of file diff --git a/database/factories/MarhunFactory.php b/database/factories/MarhunFactory.php new file mode 100644 index 0000000..ecad2f6 --- /dev/null +++ b/database/factories/MarhunFactory.php @@ -0,0 +1,32 @@ +faker = $faker; + } + + public function create() + { + static $number = 1; + + return [ + 'kodcaw' => 'KB2', + 'marhun' => 'R/L', + 't_gadai' => '2023-11-23', + 'norujukan' => ($number > 9) ? 'KB2231123-00' . $number : 'KB2231123-000' . $number , + 'bil' => 1, + 'nota' => $number++, + 'karat' => '24.0K', + 'berat' => 10.17, + 'harga' => 295.11, + 'n_marhun' => 3000.09 + ]; + } + +} \ No newline at end of file diff --git a/database/seeds/GadaiSeeder.php b/database/seeds/GadaiSeeder.php new file mode 100644 index 0000000..d94cbce --- /dev/null +++ b/database/seeds/GadaiSeeder.php @@ -0,0 +1,26 @@ +table('gadai')->insert($gadaiFactory->create()); + DB::connection('mysql')->table('marhun')->insert($gadaiFactory->create()); + } + } +} diff --git a/tinker/fakerGadai.php b/tinker/fakerGadai.php new file mode 100644 index 0000000..4117a5b --- /dev/null +++ b/tinker/fakerGadai.php @@ -0,0 +1,18 @@ +table('gadai')->insert($gadaiFactory->create()); + DB::connection('mysql')->table('marhun')->insert($marhunFactory->create()); + } + + exit(); + +?> \ No newline at end of file