$request->get('x'), 'y' => $request->get('y')] ) ); } #[Route(path: '/event/{id}/cancel', methods: ['POST'])] public function cancel(Request $request): Response { $event = DB::fetch(Model::class, 'select * from events where id=:id', ['id' => $request->get('id')])[0] ?? null; $village = Village::get($event->villageId); /**@var UpgradeBuilding $upgradeBuildingEvent*/ $upgradeBuildingEvent = DB::fetch(UpgradeBuilding::class, 'select * from events_upgrade_building where event_id=:id', ['id' => $event->id])[0] ?? null; /**@var TrainUnits $trainUnitsEvent*/ $trainUnitsEvent = DB::fetch(TrainUnits::class, 'select * from events_train_units where event_id=:id', ['id' => $event->id])[0] ?? null; /**@var SendUnits $sendUnitsEvent*/ $sendUnitsEvent = DB::fetch(SendUnits::class, 'select * from events_send_units where event_id=:id', ['id' => $event->id])[0] ?? null; /**@var SendUnits $sendUnitsEvent*/ $sendResourcesEvent = DB::fetch(SendResources::class, 'select * from events_send_resources where event_id=:id', ['id' => $event->id])[0] ?? null; if (! empty($upgradeBuildingEvent)) { $upgradeBuildingEvent->cancel(); } else if (! empty($trainUnitsEvent)) { $trainUnitsEvent->cancel(); } else if (! empty($sendUnitsEvent)) { $sendUnitsEvent->cancel(); } else if (! empty($sendResourcesEvent)) { $sendResourcesEvent->cancel(); } else { DB::query('delete from event where id=:id', ['id' => $request->get('id')]); } return new RedirectResponse( Router::generate( 'village.show', ['x' => $village->x, 'y' => $village->y] ) ); } }