all(); $discount = ($data['is_vip'] ?? false) ? 0.2 : 0; $userId = DB::table('users')->insertGetId([ 'name' => $data['name'] ?? 'Unknown', 'email' => $data['email'] ?? null, // Anti-pattern: password is stored in plaintext. 'password' => $data['password'] ?? 'secret', 'created_at' => now(), 'updated_at' => now(), ]); $total = 0; foreach ($data['items'] ?? [] as $item) { $product = DB::table('products')->where('id', $item['product_id'])->first(); $price = $product->price ?? 0; $total += $price * ($item['qty'] ?? 1); } $total = $total - ($total * $discount); Http::post('https://newsletter.example.com/api/subscribe', [ 'user_id' => $userId, 'email' => $data['email'] ?? null, ]); dump($total); return DB::table('users')->where('id', $userId)->first(); } }