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 ?PersistentCollection $additionalDiscounts;
  20.     protected Collection $beautyMasters;
  21.     public function __construct()
  22.     {
  23.         parent::__construct();
  24.         $this->active true;
  25.         $this->bepaidCredentials null;
  26.         $this->beautyMasters = new ArrayCollection();
  27.     }
  28.     public function getOffers() {
  29.         return $this->offers;
  30.     }
  31.     public function firstOffer(): Offer
  32.     {
  33.         return $this->offers->first();
  34.     }
  35.     public function setOffer($offers) {
  36.         $this->offer $offers;
  37.     }
  38.     public function getPickupPointPartnerID() {
  39.         return $this->pickupPointPartnerID;
  40.     }
  41.     public function setPickupPointPartnerID($pickupPointPartnerID) {
  42.         $this->pickupPointPartnerID $pickupPointPartnerID;
  43.     }
  44.     public function getPickupPointBelTransSatDepotID() {
  45.         return $this->pickupPointBelTransSatDepotID;
  46.     }
  47.     public function setPickupPointBelTransSatDepotID($pickupPointBelTransSatDepotID) {
  48.         $this->pickupPointBelTransSatDepotID $pickupPointBelTransSatDepotID;
  49.     }
  50.     public function getPickupPointSchedule() {
  51.         return $this->pickupPointSchedule;
  52.     }
  53.     public function setPickupPointSchedule($pickupPointSchedule) {
  54.         $this->pickupPointSchedule $pickupPointSchedule;
  55.     }
  56.     public function getPickupPointScheduleParsed() {
  57.         if (!$this->pickupPointSchedule || !(json_decode($this->pickupPointSchedule))) {
  58.             return null;
  59.         }
  60.         $schedule = [];
  61.         foreach (json_decode($this->pickupPointSchedule) as $item) {
  62.             if ($item == '') {
  63.                 $schedule[] = [];
  64.             } else {
  65.                 $daySchedule = [];
  66.                 foreach (explode(','$item) as $schedulePeriod) {
  67.                     $schedulePeriodExploded explode('-'$schedulePeriod);
  68.                     $timeFrom = \DateTime::createFromFormat("H:i"$schedulePeriodExploded[0]);
  69.                     $timeTo = \DateTime::createFromFormat("H:i"$schedulePeriodExploded[1]);
  70.                     while ($timeFrom <= $timeTo) {
  71.                         $daySchedule[] = $timeFrom->format('H:i');
  72.                         $timeFrom->modify('+30 minutes');
  73.                     }
  74.                 }
  75.                 $schedule[] = $daySchedule;
  76.             }
  77.         }
  78.         return $schedule;
  79.     }
  80.     public function jsonSerialize(): array
  81.     {
  82.         $serialized parent::jsonSerialize();
  83.         $serialized['pickupPointPartnerID'] = $this->pickupPointPartnerID;
  84.         $serialized['pickupPointSchedule'] = $this->pickupPointSchedule;
  85.         $serialized['pickupPointBelTransSatDepotID'] = $this->pickupPointBelTransSatDepotID;
  86.         $serialized['bepaidCredentials'] = $this->bepaidCredentials;
  87.         return $serialized;
  88.     }
  89.     public static function fromJSON($data): self
  90.     {
  91.         $location parent::fromJSON($data);
  92.         if (isset($data->pickupPointPartnerID)) {
  93.             $location->setPickupPointPartnerID($data->pickupPointPartnerID);
  94.             $location->setPickupPointSchedule($data->pickupPointSchedule);
  95.         }
  96.         if (isset($data->pickupPointBelTransSatDepotID)) {
  97.             $location->setPickupPointBelTransSatDepotID($data->pickupPointBelTransSatDepotID);
  98.         }
  99.         if (isset($data->bepaidCredentials)) {
  100.             $location->setBepaidCredentials($data->bepaidCredentials);
  101.         }
  102.         return $location;
  103.     }
  104.     public function getGiftCertificate() {
  105.         return $this->giftCertificate;
  106.     }
  107.     public function setGiftCertificate($giftCertificate) {
  108.         $this->giftCertificate $giftCertificate;
  109.     }
  110.     public function isActive() {
  111.         return $this->active;
  112.     }
  113.     public function setActive($active) {
  114.         $this->active $active;
  115.     }
  116.     public function getOfferId(): int
  117.     {
  118.         return $this->offerId;
  119.     }
  120.     public function setOfferId(int $offerId): void
  121.     {
  122.         $this->offerId $offerId;
  123.     }
  124.     public function getBepaidCredentials(): ?string
  125.     {
  126.         return $this->bepaidCredentials;
  127.     }
  128.     public function setBepaidCredentials(?string $bepaidCredentials): void
  129.     {
  130.         $this->bepaidCredentials $bepaidCredentials;
  131.     }
  132.     public function getBeautyMasters(): Collection
  133.     {
  134.         return $this->beautyMasters;
  135.     }
  136. }