$this->id])->fetchAll(); foreach ($meta as $m) { $unit = DB::query('select * from village_units where id=:unitId', ['unitId' => $m['unit_id']])->fetch(); DB::query('update village_units set amount=amount+:amount where id=:unitId', ['amount' => $m['amount'], 'unitId' => $unit['id']]); DB::query( 'update village_units set amount=amount-:amount where type=:unitType and home_village_id=:homeVillageId and residence_village_id=:residenceVillageId and is_traveling=true', [ 'amount' => $m['amount'], 'unitType' => $unit['type'], 'homeVillageId' => $unit['home_village_id'], 'residenceVillageId' => $unit['residence_village_id'], ] ); } } public function cancel(): void {} public function dbInsert(): void { DB::query( 'insert into events (time, village_id) VALUES (:time, :village_id)', ['time' => $this->event->time->format('c'), 'village_id' => $this->event->villageId] ); $eventId = DB::$connection->lastInsertId(); DB::query( << $eventId, 'source' => $this->source, 'destination' => $this->destination, ] ); $sendResourcesCarriersEventId = DB::$connection->lastInsertId(); DB::query( 'update events_meta_send_resources_carriers set event_id=:new_id where event_id=:old_id', ['old_id' => $this->sendResourcesEventId, 'new_id' => $sendResourcesCarriersEventId] ); } public function dbDelete(): void { DB::query('delete from events where id=:id', ['id' => $this->eventId]); DB::query('delete from events_send_resources_carriers where id=:id', ['id' => $this->id]); DB::query('delete from events_meta_send_resources_carriers where event_id=:id', ['id' => $this->id]); } }