src/Entity/GeoLocation.php line 9

Open in your IDE?
  1. <?php
  2. namespace Slivki\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\PersistentCollection;
  6. class GeoLocation extends AbstractGeoLocationBase implements \JsonSerializable
  7. {
  8.     public const SRID 4326;
  9.     public const DEFAULT_LOCATION = [53.91172427.557008];
  10.     public const TYPE 0;
  11.     protected $offers;
  12.     protected $pickupPointPartnerID;
  13.     protected $pickupPointBelTransSatDepotID;
  14.     protected $pickupPointSchedule;
  15.     protected $giftCertificate;
  16.     protected $active;
  17.     protected int $offerId;
  18.     protected ?string $bepaidCredentials;
  19.     private ?string $callbackChatId null;
  20.     private ?PersistentCollection $additionalDiscounts;
  21.     protected Collection $beautyMasters;
  22.     public function __construct()
  23.     {
  24.         parent::__construct();
  25.         $this->active true;
  26.         $this->bepaidCredentials null;
  27.         $this->beautyMasters = new ArrayCollection();
  28.     }
  29.     public function getOffers() {
  30.         return $this->offers;
  31.     }
  32.     public function firstOffer(): Offer
  33.     {
  34.         return $this->offers->first();
  35.     }
  36.     public function setOffer($offers) {
  37.         $this->offer $offers;
  38.     }
  39.     public function getPickupPointPartnerID() {
  40.         return $this->pickupPointPartnerID;
  41.     }
  42.     public function setPickupPointPartnerID($pickupPointPartnerID) {
  43.         $this->pickupPointPartnerID $pickupPointPartnerID;
  44.     }
  45.     public function getPickupPointBelTransSatDepotID() {
  46.         return $this->pickupPointBelTransSatDepotID;
  47.     }
  48.     public function setPickupPointBelTransSatDepotID($pickupPointBelTransSatDepotID) {
  49.         $this->pickupPointBelTransSatDepotID $pickupPointBelTransSatDepotID;
  50.     }
  51.     public function getPickupPointSchedule() {
  52.         return $this->pickupPointSchedule;
  53.     }
  54.     public function setPickupPointSchedule($pickupPointSchedule) {
  55.         $this->pickupPointSchedule $pickupPointSchedule;
  56.     }
  57.     public function getPickupPointScheduleParsed() {
  58.         if (!$this->pickupPointSchedule || !(json_decode($this->pickupPointSchedule))) {
  59.             return null;
  60.         }
  61.         $schedule = [];
  62.         foreach (json_decode($this->pickupPointSchedule) as $item) {
  63.             if ($item == '') {
  64.                 $schedule[] = [];
  65.             } else {
  66.                 $daySchedule = [];
  67.                 foreach (explode(','$item) as $schedulePeriod) {
  68.                     $schedulePeriodExploded explode('-'$schedulePeriod);
  69.                     $timeFrom = \DateTime::createFromFormat("H:i"$schedulePeriodExploded[0]);
  70.                     $timeTo = \DateTime::createFromFormat("H:i"$schedulePeriodExploded[1]);
  71.                     while ($timeFrom <= $timeTo) {
  72.                         $daySchedule[] = $timeFrom->format('H:i');
  73.                         $timeFrom->modify('+30 minutes');
  74.                     }
  75.                 }
  76.                 $schedule[] = $daySchedule;
  77.             }
  78.         }
  79.         return $schedule;
  80.     }
  81.     public function jsonSerialize(): array
  82.     {
  83.         $serialized parent::jsonSerialize();
  84.         $serialized['pickupPointPartnerID'] = $this->pickupPointPartnerID;
  85.         $serialized['pickupPointSchedule'] = $this->pickupPointSchedule;
  86.         $serialized['pickupPointBelTransSatDepotID'] = $this->pickupPointBelTransSatDepotID;
  87.         $serialized['bepaidCredentials'] = $this->bepaidCredentials;
  88.         $serialized['callbackChatId'] = $this->callbackChatId;
  89.         return $serialized;
  90.     }
  91.     public static function fromJSON($data): self
  92.     {
  93.         $location parent::fromJSON($data);
  94.         if (isset($data->callbackChatId)) {
  95.             $location->setCallbackChatId($data->callbackChatId);
  96.         }
  97.         if (isset($data->pickupPointPartnerID)) {
  98.             $location->setPickupPointPartnerID($data->pickupPointPartnerID);
  99.             $location->setPickupPointSchedule($data->pickupPointSchedule);
  100.         }
  101.         if (isset($data->pickupPointBelTransSatDepotID)) {
  102.             $location->setPickupPointBelTransSatDepotID($data->pickupPointBelTransSatDepotID);
  103.         }
  104.         if (isset($data->bepaidCredentials)) {
  105.             $location->setBepaidCredentials($data->bepaidCredentials);
  106.         }
  107.         return $location;
  108.     }
  109.     public function getGiftCertificate() {
  110.         return $this->giftCertificate;
  111.     }
  112.     public function setGiftCertificate($giftCertificate) {
  113.         $this->giftCertificate $giftCertificate;
  114.     }
  115.     public function isActive() {
  116.         return $this->active;
  117.     }
  118.     public function setActive($active) {
  119.         $this->active $active;
  120.     }
  121.     public function getOfferId(): int
  122.     {
  123.         return $this->offerId;
  124.     }
  125.     public function setOfferId(int $offerId): void
  126.     {
  127.         $this->offerId $offerId;
  128.     }
  129.     public function getBepaidCredentials(): ?string
  130.     {
  131.         return $this->bepaidCredentials;
  132.     }
  133.     public function setBepaidCredentials(?string $bepaidCredentials): void
  134.     {
  135.         $this->bepaidCredentials $bepaidCredentials;
  136.     }
  137.     public function getBeautyMasters(): Collection
  138.     {
  139.         return $this->beautyMasters;
  140.     }
  141.     public function getCallbackChatId(): ?string
  142.     {
  143.         return $this->callbackChatId;
  144.     }
  145.     public function setCallbackChatId(?string $callbackChatId): void
  146.     {
  147.         $this->callbackChatId $callbackChatId;
  148.     }
  149. }