diff --git a/app/.DS_Store b/app/.DS_Store index aba4526..c05d45c 100644 Binary files a/app/.DS_Store and b/app/.DS_Store differ diff --git a/app/Http/Controllers/PampasanController.php b/app/Http/Controllers/PampasanController.php new file mode 100644 index 0000000..6592327 --- /dev/null +++ b/app/Http/Controllers/PampasanController.php @@ -0,0 +1,94 @@ +validate($request, [ + 'norujukan' => 'required|string', + 'baucerno' => 'required|string', + 'kodcaw' => 'required|string', + 'jumlah_pampasan' => 'required|numeric', + 'denominasi' => 'nullable|array', + 'teller' => 'required|string', + ]); + + try { + $cawangan = Cawangan::on('mysql7')->where('kodcaw', $request->kodcaw)->first(); + + if (!$cawangan) { + return response()->json([ + 'success' => false, + 'message' => 'Cawangan tidak dijumpai untuk kodcaw: ' . $request->kodcaw, + ], 404); + } + + $pampasan = Pampasan::on($cawangan['mysql'])->create([ + 'norujukan' => $validated['norujukan'], + 'baucerno' => $validated['baucerno'], + 'kodcaw' => $validated['kodcaw'], + 'jumlah_pampasan' => $validated['jumlah_pampasan'], + 'denominasi' => isset($validated['denominasi']) ? json_encode($validated['denominasi']) : null, + 'teller' => $validated['teller'], + ]); + + return response()->json([ + 'success' => true, + 'message' => 'Pampasan berjaya dibayar.', + 'data' => $pampasan, + ], 201); + } catch (\Exception $e) { + return response()->json([ + 'success' => false, + 'message' => 'Database error: ' . $e->getMessage(), + ], 500); + } + } + + public function updateStatusPampasan(Request $request) + { + $norujukan = $request->norujukan; + $kodcaw = $request->kodcaw; + + $cawangan = Cawangan::on('mysql7')->where('kodcaw', $request->kodcaw)->first(); + + $pampasan = Pampasan::on($cawangan['mysql'])->where("norujukan", $norujukan)->first(); + + $pampasan->status = 1; + + $pampasan->save(); + + // dd($pampasan); + + return response()->json([ + 'success' => true, + 'message' => 'Status Pampasan berjaya dituntut.', + 'data' => $pampasan, + ], 201); + } + + public function getPampasan() + { + $pampasan = Pampasan::on('mysql71')->get(); + + return response()->json([ + 'success' => true, + 'message' => 'Status Pampasan berjaya dituntut.', + 'data' => $pampasan, + ], 201); + } + + public function getPampasanByNoRujukan() + { + + } +} diff --git a/app/Pampasan.php b/app/Pampasan.php new file mode 100644 index 0000000..5aed11d --- /dev/null +++ b/app/Pampasan.php @@ -0,0 +1,33 @@ +hasColumn('palsu', 'norujukan')) { // Add index to norujukan column for better performance - $table->index('norujukan'); + // $table->index('norujukan'); // Add foreign key constraint named 'norujukan' - $table->foreign('norujukan', 'norujukan')->references('norujukan')->on('gadai'); + // $table->foreign('norujukan', 'norujukan')->references('norujukan')->on('gadai'); } }); @@ -87,21 +87,21 @@ class AddNmJbgUntungPembiayaanColumnsToPalsuTable extends Migration Schema::connection($dbase)->table('palsu', function (Blueprint $table) use ($dbase) { // Drop foreign key constraint and index from norujukan column - if (Schema::connection($dbase)->hasColumn('palsu', 'norujukan')) { - try { - $table->dropForeign('norujukan'); - echo "Dropped foreign key 'norujukan' on connection '{$dbase}'\n"; - } catch (\Exception $e) { - echo "Warning: Could not drop foreign key 'norujukan' on connection '{$dbase}': " . $e->getMessage() . "\n"; - } + // if (Schema::connection($dbase)->hasColumn('palsu', 'norujukan')) { + // try { + // $table->dropForeign('norujukan'); + // echo "Dropped foreign key 'norujukan' on connection '{$dbase}'\n"; + // } catch (\Exception $e) { + // echo "Warning: Could not drop foreign key 'norujukan' on connection '{$dbase}': " . $e->getMessage() . "\n"; + // } - try { - $table->dropIndex(['norujukan']); - echo "Dropped index on 'norujukan' column on connection '{$dbase}'\n"; - } catch (\Exception $e) { - echo "Warning: Could not drop index on 'norujukan' on connection '{$dbase}': " . $e->getMessage() . "\n"; - } - } + // try { + // $table->dropIndex(['norujukan']); + // echo "Dropped index on 'norujukan' column on connection '{$dbase}'\n"; + // } catch (\Exception $e) { + // echo "Warning: Could not drop index on 'norujukan' on connection '{$dbase}': " . $e->getMessage() . "\n"; + // } + // } // Drop other columns if they exist $columnsToCheck = ['nilaimarhun', 'jbg', 'untung','untungonepercent','untungcajlain', 'pembiayaan']; diff --git a/database/migrations/2025_08_28_150140_create_pampasan_table.php b/database/migrations/2025_08_28_150140_create_pampasan_table.php new file mode 100644 index 0000000..3c867a7 --- /dev/null +++ b/database/migrations/2025_08_28_150140_create_pampasan_table.php @@ -0,0 +1,57 @@ +select('SELECT 1'); + return true; + } catch (\Exception $e) { + return false; + } + }); + return $db_connection ? array_values($db_connection) : []; + } + + public function up() + { + foreach ($this->getActiveDB() as $dbase) { + if (!Schema::connection($dbase)->hasTable('pampasan')) { + Schema::connection($dbase)->create('pampasan', function (Blueprint $table) { + $table->bigIncrements('id'); + $table->string('norujukan', 50)->unique()->index(); + $table->string('baucerno', 30)->index(); + $table->string('kodcaw', 20)->index(); + $table->decimal('jumlah_pampasan', 11, 2); + + if (Schema::getConnection()->getPdo()->getAttribute(PDO::ATTR_SERVER_VERSION) >= '5.7') { + $table->json('denominasi')->nullable(); + } else { + $table->longText('denominasi')->nullable(); + } + $table->string('teller', 100); + $table->tinyInteger('status') + ->default(0) + ->comment('0 = belum dituntut, 1 = dituntut'); + $table->timestamps(); + }); + } + } + } + + public function down() + { + foreach ($this->getActiveDB() as $dbase) { + Schema::connection($dbase)->dropIfExists('pampasan'); + } + } +} diff --git a/routes/web.php b/routes/web.php index 9f025c3..fcb9b81 100644 --- a/routes/web.php +++ b/routes/web.php @@ -379,6 +379,11 @@ $router->group(['prefix'=>'api'], function () use ($router){ $router->post('CreatePanjar/{kodcaw}',['uses'=>'PanjarController@create']); $router->post('DeletePanjar/{kodcaw}',['uses'=>'PanjarController@delete']); + //API PAMPASAN GUNA PANJAR + $router->post('pampasan/terimaPampasan',['uses'=>'PampasanController@terimaPampasan']); + $router->put('pampasan/updateStatusPampasan', ['uses' => 'PampasanController@updateStatusPampasan']); + $router->get('pampasan', ['uses' => 'PampasanController@getPampasan']); + //API KELULUSAN $router->get('SenaraiKelulusan/{kodcaw}',['uses'=>'KelulusanController@list']);