diff options
Diffstat (limited to 'src/Model/Event/SendUnits.php')
-rw-r--r-- | src/Model/Event/SendUnits.php | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/Model/Event/SendUnits.php b/src/Model/Event/SendUnits.php index ed4d5b6..c9afd6e 100644 --- a/src/Model/Event/SendUnits.php +++ b/src/Model/Event/SendUnits.php @@ -102,6 +102,27 @@ class SendUnits extends BaseEvent ); } + public function cancel(): void + { + $this->event = $this->getEvent(); + + $cancelTimeDiff = $this->event->createdAt->diff(new \DateTime()); + $cancelTime = (new \DateTime())->add($cancelTimeDiff); + + $this->isCanceled = true; + $this->home = $this->destination; + $this->residence = $this->source; + + DB::query( + 'update events set time=:time where id=:id', + ['time' => $cancelTime->format('c'), 'id' => $this->event->id] + ); + DB::query( + 'update events_send_units set is_canceled=:is_canceled, home=:home, residence=:residence where id=:id', + ['is_canceled' => $this->isCanceled, 'home' => $this->home, 'residence' => $this->residence, 'id' => $this->id] + ); + } + public function dbInsert(): void { DB::query( |