Latihan 1: Arsitektur & Best Practices — Laravel

Latihan 1 dari materi Arsitektur & Best Practices di Laravel — praktek dengan editor kode interaktif, test case otomatis, dan hint terpandu. Langsung jalan di browser.

Buat OrderService class dengan method place(array $items): array yang:

  1. Menghitung total harga dari array items (setiap item punya price dan quantity)
  2. Return array ["total" => $total, "item_count" => count($items), "status" => "placed"]

Buat route POST /orders yang menggunakan service ini.

Hint