| @@ -185,9 +185,9 @@ | ||
| 185 | 185 | * without `id` is created. Returns per-row result objects so the caller can |
| 186 | 186 | * surface partial failures. Cache invalidation fires once at the end (via |
| 187 | 187 | * the existing per-row hooks already invoked by the repository). |
| 188 | 188 | * |
| 189 | - * @param int $dayId The yatra_new_trip_itinerary_days.id row. | |
| 189 | + * @param int $dayId The yatra_trip_itinerary_days.id row. | |
| 190 | 190 | * @param int $tripId The trip id (used for the create branch). |
| 191 | 191 | * @param array $activities Array of activity payloads. Each row may include |
| 192 | 192 | * an `id` (update) or omit it (create). |
| 193 | 193 | * @return array {created: int, updated: int, results: array} |
| @@ -281,25 +281,24 @@ | ||
| 281 | 281 | * Bulk delete itinerary entries |
| 282 | 282 | * @param array $ids Array of entry IDs to delete |
| 283 | 283 | * @return array ['deleted' => count, 'failed' => count] |
| 284 | 284 | */ |
| 285 | - public function bulkDelete(array $ids): array | |
| 285 | + public function bulkDelete(array $ids, array $dayIds = []): array | |
| 286 | 286 | { |
| 287 | - if (empty($ids)) { | |
| 288 | - return ['deleted' => 0, 'failed' => 0]; | |
| 289 | - } | |
| 290 | - | |
| 291 | - // Validate all IDs are integers | |
| 292 | - $ids = array_map('intval', $ids); | |
| 293 | - $ids = array_filter($ids, function($id) { | |
| 287 | + // Activity entry ids and day ids are validated independently — see | |
| 288 | + // ItineraryRepository::bulkDelete() for why they must stay separate. | |
| 289 | + $ids = array_values(array_filter(array_map('intval', $ids), function ($id) { | |
| 294 | 290 | return $id > 0; |
| 295 | - }); | |
| 291 | + })); | |
| 292 | + $dayIds = array_values(array_filter(array_map('intval', $dayIds), function ($id) { | |
| 293 | + return $id > 0; | |
| 294 | + })); | |
| 296 | 295 | |
| 297 | - if (empty($ids)) { | |
| 296 | + if (empty($ids) && empty($dayIds)) { | |
| 298 | 297 | return ['deleted' => 0, 'failed' => 0]; |
| 299 | 298 | } |
| 300 | 299 | |
| 301 | - return $this->repository->bulkDelete($ids); | |
| 300 | + return $this->repository->bulkDelete($ids, $dayIds); | |
| 302 | 301 | } |
| 303 | 302 | |
| 304 | 303 | /** |
| 305 | 304 | * Get all itinerary entries for a specific trip |