From 6fb2ab0d5762a82b4481043afda103a1c94c86bf Mon Sep 17 00:00:00 2001 From: iFannJR Date: Mon, 22 Jun 2026 00:02:58 +0700 Subject: [PATCH] perbaiki tampilan --- app/Http/Controllers/CheckoutController.php | 4 +- app/Http/Controllers/HomeController.php | 2 +- app/Models/Transaction.php | 1 + app/Services/ToyRecommendationService.php | 21 ++- resources/views/user/checkout.blade.php | 133 +++++++++++------- .../user/recommendation-result.blade.php | 2 +- resources/views/user/recommendation.blade.php | 10 +- resources/views/welcome.blade.php | 2 +- 8 files changed, 102 insertions(+), 73 deletions(-) diff --git a/app/Http/Controllers/CheckoutController.php b/app/Http/Controllers/CheckoutController.php index 9178ce8..6e3048c 100644 --- a/app/Http/Controllers/CheckoutController.php +++ b/app/Http/Controllers/CheckoutController.php @@ -17,7 +17,7 @@ public function show() return redirect()->route('cart.index')->with('error', 'Keranjang kosong.'); } $total = $items->sum(fn ($item) => $item->quantity * $item->product->price); - $pickupStart = config('store.pickup_start', '19:00'); + $pickupStart = config('store.pickup_start', '07:00'); $pickupEnd = config('store.pickup_end', '21:00'); return view('user.checkout', compact('items', 'total', 'pickupStart', 'pickupEnd')); @@ -42,7 +42,7 @@ public function process(CheckoutRequest $request) $code = 'TRX-' . strtoupper(Str::random(8)); $pickupDateTime = Carbon::parse($request->pickup_date . ' ' . $request->pickup_time); - $pickupStartDateTime = Carbon::parse($request->pickup_date . ' ' . config('store.pickup_start', '19:00')); + $pickupStartDateTime = Carbon::parse($request->pickup_date . ' ' . config('store.pickup_start', '07:00')); $pickupEndDateTime = Carbon::parse($request->pickup_date . ' ' . config('store.pickup_end', '21:00')); if ($pickupDateTime->lt(now())) { diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index 2ac2f76..3227daf 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -22,7 +22,7 @@ public function index() public function dashboard() { $user = auth()->user(); - $totalTransactions = Transaction::where('user_id', $user->id)->count(); + $totalTransactions = Transaction::where('user_id', $user->id)->count();// $recentTransactions = Transaction::where('user_id', $user->id) ->latest() ->take(3) diff --git a/app/Models/Transaction.php b/app/Models/Transaction.php index 1a5d710..999da82 100644 --- a/app/Models/Transaction.php +++ b/app/Models/Transaction.php @@ -18,6 +18,7 @@ class Transaction extends Model 'stock_restored_at' => 'datetime', ]; + //status: pending, paid, cancelled public static function cancelOverduePendingPickup(): void { static::query() diff --git a/app/Services/ToyRecommendationService.php b/app/Services/ToyRecommendationService.php index a4e8499..b0f88f4 100644 --- a/app/Services/ToyRecommendationService.php +++ b/app/Services/ToyRecommendationService.php @@ -250,13 +250,12 @@ public function getRecommendationsWithMatrix(array $input): array } protected function getFilteredProducts( - int $ageMin, - int $ageMax, - float $budgetMin, - float $budgetMax, - ?string $category = null -): Collection -{ + int $ageMin, + int $ageMax, + float $budgetMin, + float $budgetMax, + ?string $category = null + ): Collection { $query = Product::with('criterias') ->where('stock', '>', 0) ->whereBetween('price', [$budgetMin, $budgetMax]); @@ -386,10 +385,10 @@ protected function normalizeMatrix(array $matrix, Collection $criterias): array foreach ($criterias as $criteria) { $key = $criteria->name; - $values = array_column($matrix, $key); - $max = max($values); - $min = min($values); - $isCost = $criteria->type === 'cost'; + $values = array_column($matrix, $key); //Mengambil seluruh nilai dari suatu kriteria. + $max = max($values); //Mencari nilai terbesar. + $min = min($values); //Mencari nilai terkecil + $isCost = $criteria->type === 'cost';//Mengecek apakah kriteria termasuk Cost atau Benefit. if ($isCost) { foreach ($matrix as $pid => $row) { diff --git a/resources/views/user/checkout.blade.php b/resources/views/user/checkout.blade.php index 7ec110a..1428932 100644 --- a/resources/views/user/checkout.blade.php +++ b/resources/views/user/checkout.blade.php @@ -3,58 +3,87 @@ @section('title', 'Checkout') @section('content') -
-

Checkout

+
+

Checkout

-
- @csrf - -

Pengambilan di Toko

-
-
-

Alamat toko

-
- {{ config('store.address') }} -
-
-
-

No. telepon toko

-
- {{ config('store.phone') }} -
-
-
- - -
-
-
- - -
-
- - -
-
-

Jam operasional pengambilan: {{ $pickupStart }} - {{ $pickupEnd }}. Pesanan otomatis dibatalkan jika melewati jam pengambilan.

-
-
-
+ + @csrf -

Ringkasan pesanan

-
    - @foreach($items as $item) -
  • - {{ $item->product->name }} × {{ $item->quantity }} - Rp {{ number_format($item->quantity * $item->product->price, 0, ',', '.') }} -
  • - @endforeach -
-

Total: Rp {{ number_format($total, 0, ',', '.') }}

+

Pengambilan di Toko

+
+
+

Alamat toko

+
+ {{ config('store.address') }} +
+
+
+

No. telepon toko

+
+ {{ config('store.phone') }} +
+
+
+ + +
+
+
+ + +
+
+ + + +
+
+

Jam operasional pengambilan: {{ $pickupStart }} - {{ $pickupEnd }}. + Pesanan otomatis dibatalkan jika melewati jam pengambilan.

+
- Buat pesanan -
-
-
-@endsection +
+ +

Ringkasan pesanan

+
    + @foreach($items as $item) +
  • + {{ $item->product->name }} × {{ $item->quantity }} + Rp + {{ number_format($item->quantity * $item->product->price, 0, ',', '.') }} +
  • + @endforeach +
+

Total: Rp + {{ number_format($total, 0, ',', '.') }} +

+
+ Buat pesanan +
+ +
+@endsection \ No newline at end of file diff --git a/resources/views/user/recommendation-result.blade.php b/resources/views/user/recommendation-result.blade.php index 8259fe4..c3c7468 100644 --- a/resources/views/user/recommendation-result.blade.php +++ b/resources/views/user/recommendation-result.blade.php @@ -81,7 +81,7 @@ {{ $c['name'] }} {{ $c['type'] === 'cost' ? 'Cost' : 'Benefit' }} - {{ number_format($c['weight'], 4) }} + {{ number_format($c['weight'], 9) }} @endforeach diff --git a/resources/views/user/recommendation.blade.php b/resources/views/user/recommendation.blade.php index 7036c95..e2dc615 100644 --- a/resources/views/user/recommendation.blade.php +++ b/resources/views/user/recommendation.blade.php @@ -20,15 +20,15 @@
- + value="{{ old('budget_min', 50000) }}" min="0" required />
- + @foreach($categories as $category)