$proposal->registration_value, 'registration_included_in_course' => (bool) $proposal->registration_included_in_course, 'registration_installments_allowed' => (bool) $proposal->registration_installments_allowed, 'registration_max_installments' => $proposal->registration_max_installments, 'classes_value' => $proposal->classes_value, 'classes_included_in_course' => (bool) $proposal->classes_included_in_course, 'classes_installments_allowed' => (bool) $proposal->classes_installments_allowed, 'classes_max_installments' => $proposal->classes_max_installments, 'classes_discount_percentage' => $proposal->classes_discount_percentage, 'materials_total_value' => $proposal->materials_total_value, 'materials_included_in_course' => (bool) $proposal->materials_included_in_course, 'materials_installments_allowed' => (bool) $proposal->materials_installments_allowed, 'materials_max_installments' => $proposal->materials_max_installments, 'total_value' => $proposal->total_value, 'total_max_installments' => $proposal->total_max_installments, 'materials' => $proposal->relationLoaded('products') ? $proposal->products->map(fn($item) => [ 'product_id' => $item->product_id, 'name' => $item->product?->name, 'quantity' => $item->quantity, 'price' => (float) $item->price, ]) : [], ]; if ($withCondition) { $array['condition'] = $proposal->condition; } return $array; } }