fix(saw): kecepatan_layanan harus Cost bukan Benefit, fix custom bobot key mapping untuk Fasilitas layanan

This commit is contained in:
micko samawa 2026-06-28 14:36:40 +07:00
parent 6ccd792d78
commit 3c0227a557
3 changed files with 42 additions and 1 deletions

View File

@ -312,7 +312,7 @@ public function calculateLaundry(Request $request)
'harga' => $request->bobot_harga / 100,
'jarak' => $request->bobot_jarak / 100,
'kecepatan_layanan' => $request->bobot_kecepatan / 100,
'layanan' => $request->bobot_layanan / 100,
'Fasilitas layanan' => $request->bobot_layanan / 100,
];
}
}
@ -626,6 +626,7 @@ private function getNilaiLaundry($item, $field, $jenisLayanan = null)
return $waktu > 0 ? $waktu : 24;
case 'layanan':
case 'Fasilitas layanan':
// Jumlah variasi layanan yang tersedia
return $item->layanan->count() ?: 1;

View File

@ -0,0 +1,21 @@
<?php
require __DIR__ . '/vendor/autoload.php';
$app = require_once __DIR__ . '/bootstrap/app.php';
$app->make(\Illuminate\Contracts\Console\Kernel::class)->bootstrap();
echo "=== ALL KONTRAKANS ===\n";
foreach (\App\Models\Kontrakan::with('galeri')->get() as $k) {
echo "ID: {$k->id} | Nama: {$k->nama}\n";
echo " foto: " . var_export($k->foto, true) . "\n";
echo " galeri count: " . count($k->galeri) . "\n";
foreach ($k->galeri as $g) {
echo " - galeri: " . $g->foto . " (is_primary: " . var_export($g->is_primary, true) . ")\n";
}
}
echo "\n=== ALL LAUNDRIES ===\n";
foreach (\App\Models\Laundry::with('galeri')->get() as $l) {
echo "ID: {$l->id} | Nama: {$l->nama}\n";
echo " foto: " . var_export($l->foto, true) . "\n";
echo " galeri count: " . count($l->galeri) . "\n";
}

View File

@ -0,0 +1,19 @@
<?php
require __DIR__ . '/vendor/autoload.php';
$app = require_once __DIR__ . '/bootstrap/app.php';
$app->make(\Illuminate\Contracts\Console\Kernel::class)->bootstrap();
$request = \Illuminate\Http\Request::create('/api/saw/calculate/kontrakan', 'POST', [
'bobot_harga' => 25,
'bobot_jarak' => 25,
'bobot_jumlah_kamar' => 25,
'bobot_fasilitas' => 25,
]);
$controller = new \App\Http\Controllers\Api\SAWController();
$response = $controller->calculateKontrakan($request);
echo "Status Code: " . $response->getStatusCode() . "\n";
echo "Content: \n";
$data = json_decode($response->getContent(), true);
echo json_encode($data, JSON_PRETTY_PRINT);