src/Evo/Infrastructure/MappingORM/Store.php line 36

Open in your IDE?
  1. <?php
  2. namespace Evo\Infrastructure\MappingORM;
  3. use ApiPlatform\Core\Annotation\ApiFilter;
  4. use ApiPlatform\Core\Annotation\ApiResource;
  5. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
  6. use ApiPlatform\Core\Serializer\Filter\PropertyFilter;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. use Doctrine\Common\Collections\Collection;
  9. use Doctrine\ORM\Mapping as ORM;
  10. use Symfony\Component\Serializer\Annotation\Groups;
  11. /**
  12.  * Store entity.
  13.  *
  14.  * @ApiResource(attributes={
  15.  *     "normalization_context"={"groups"={"read_store"}},
  16.  *     "denormalization_context"={"groups"={"write_store"}}
  17.  * },
  18.  *     cacheHeaders={"max_age"=86400, "shared_max_age"=86400},
  19.  *     itemOperations={"get", "put"})
  20.  * @ApiFilter(SearchFilter::class, properties={
  21.  *     "postalAddress.postalCode": "exact",
  22.  *     "status":"exact",
  23.  *     "sector.id": "exact",
  24.  *     "sector": "exact",
  25.  *     "sector.name": "exact",
  26.  *     "name": "start"
  27.  * })
  28.  * @ApiFilter(PropertyFilter::class)
  29.  * @ORM\Entity
  30.  * @ORM\Table(name="store")
  31.  * @ORM\Entity(repositoryClass="App\Repository\StoreRepository")
  32.  */
  33. class Store
  34. {
  35.     /**
  36.      * @var int The entity Id
  37.      *
  38.      * @ORM\Column(type="integer")
  39.      * @ORM\Id
  40.      * @ORM\GeneratedValue(strategy="AUTO")
  41.      * @Groups({"read_store", "read_organization", "read_discount", "read_pack", "admin_orga_list", "read_discount_for_select", "read_product_with_store"})
  42.      */
  43.     private int $id;
  44.     /**
  45.      * @var string The store name
  46.      *
  47.      * @Groups({"read_store", "write_store", "read_user", "read_organization", "write_organization", "read_discount", "read_pack", "admin_orga_list", "read_discount_for_select", "read_product_with_store"})
  48.      * @ORM\Column(type="string")
  49.      */
  50.     private ?string $name null;
  51.     /**
  52.      * @Groups({"read_store", "write_store", "read_user", "read_organization", "write_organization", "admin:orga:select",})
  53.      * @ORM\OneToOne(targetEntity="PostalAddress", cascade={"persist"})
  54.      * @ORM\JoinColumn(name="postal_address_id", referencedColumnName="id")
  55.      */
  56.     private ?PostalAddress $postalAddress null;
  57.     /**
  58.      * @var array The store opening hours
  59.      *
  60.      * @Groups({"read_store", "write_store", "read_organization", "write_organization"})
  61.      * @ORM\Column(type="array")
  62.      */
  63.     private $openingHours;
  64.     /**
  65.      * @var array The store currencies accepted
  66.      *
  67.      * @Groups({"read_store", "write_store", "read_organization", "write_organization"})
  68.      * @ORM\Column(type="array")
  69.      */
  70.     private $currenciesAccepted;
  71.     /**
  72.      * @var string The store type of the accepted payment
  73.      *
  74.      * @Groups({"read_store", "write_store", "read_organization", "write_organization"})
  75.      * @ORM\Column(type="string")
  76.      */
  77.     private ?string $paymentAcceptedType null;
  78.     /**
  79.      * @var array The store price range
  80.      *
  81.      * @Groups({"read_store", "write_store", "read_organization", "write_organization"})
  82.      * @ORM\Column(type="array")
  83.      */
  84.     private $priceRange;
  85.     /**
  86.      * @var int The store aggregate rating
  87.      *
  88.      * @Groups({"read_store", "write_store", "read_organization", "write_organization"})
  89.      * @ORM\Column(type="integer", nullable=true)
  90.      */
  91.     private ?int $aggregateRating null;
  92.     /**
  93.      * @Groups({"read_store", "read_organization"})
  94.      * @ORM\Column(name="created_at", type="datetime")
  95.      */
  96.     private ?\DateTimeInterface $createdAt;
  97.     /**
  98.      * @ORM\OneToMany(targetEntity="Evo\Infrastructure\MappingORM\Organization", mappedBy="store")
  99.      */
  100.     private ?Collection $organizations;
  101.     /**
  102.      * @Groups({"read_store", "read_organization"})
  103.      * @ORM\Column(type="string", length=255, nullable=true)
  104.      */
  105.     private ?string $prefectoralApprovalNumber null;
  106.     /**
  107.      * @Groups({"read_store", "read_organization"})
  108.      * @ORM\Column(type="string", length=255, nullable=true)
  109.      */
  110.     private ?string $status null;
  111.     /**
  112.      * @Groups({"read_store", "read_organization"})
  113.      * @ORM\Column(type="string", length=255, nullable=true)
  114.      */
  115.     private ?string $cedex null;
  116.     /**
  117.      * @ORM\ManyToMany(targetEntity=DiscountCode::class, mappedBy="store")
  118.      */
  119.     private ?Collection $discountCodes;
  120.     /**
  121.      * @Groups({"read_store", "read_organization"})
  122.      * @ORM\ManyToOne(targetEntity=Sector::class, inversedBy="stores")
  123.      */
  124.     private ?Sector $sector null;
  125.     /**
  126.      * @ORM\OneToMany(targetEntity=BAL::class, mappedBy="store", orphanRemoval=true)
  127.      */
  128.     private Collection $bal;
  129.     /**
  130.      * @ORM\Column(type="boolean")
  131.      */
  132.     private bool $isExportableIbml false;
  133.     public function __construct()
  134.     {
  135.         $this->organizations = new ArrayCollection();
  136.         $this->createdAt = new \DateTime();
  137.         $this->discountCodes = new ArrayCollection();
  138.         $this->bal = new ArrayCollection();
  139.     }
  140.     public function __toString()
  141.     {
  142.         return $this->name;
  143.     }
  144.     /**
  145.      * @return int
  146.      */
  147.     public function getId()
  148.     {
  149.         return $this->id;
  150.     }
  151.     /**
  152.      * @return string
  153.      */
  154.     public function getName()
  155.     {
  156.         return $this->name;
  157.     }
  158.     public function setName(string $name): Store
  159.     {
  160.         $this->name $name;
  161.         return $this;
  162.     }
  163.     /**
  164.      * @return PostalAddress
  165.      */
  166.     public function getPostalAddress()
  167.     {
  168.         return $this->postalAddress;
  169.     }
  170.     public function getStandardizedAddress(): ?string
  171.     {
  172.         return $this->postalAddress ? ($this->postalAddress->getStandardizedAddress() ?: $this->postalAddress->getStreetAddress()) : null;
  173.     }
  174.     public function setPostalAddress(PostalAddress $postalAddress): Store
  175.     {
  176.         $this->postalAddress $postalAddress;
  177.         return $this;
  178.     }
  179.     /**
  180.      * @return array
  181.      */
  182.     public function getOpeningHours()
  183.     {
  184.         return $this->openingHours;
  185.     }
  186.     public function setOpeningHours(array $openingHours): Store
  187.     {
  188.         $this->openingHours $openingHours;
  189.         return $this;
  190.     }
  191.     /**
  192.      * @return array
  193.      */
  194.     public function getCurrenciesAccepted()
  195.     {
  196.         return $this->currenciesAccepted;
  197.     }
  198.     public function setCurrenciesAccepted(array $currenciesAccepted): Store
  199.     {
  200.         $this->currenciesAccepted $currenciesAccepted;
  201.         return $this;
  202.     }
  203.     /**
  204.      * @return string
  205.      */
  206.     public function getPaymentAcceptedType()
  207.     {
  208.         return $this->paymentAcceptedType;
  209.     }
  210.     public function setPaymentAcceptedType(string $paymentAcceptedType): Store
  211.     {
  212.         $this->paymentAcceptedType $paymentAcceptedType;
  213.         return $this;
  214.     }
  215.     /**
  216.      * @return array
  217.      */
  218.     public function getPriceRange()
  219.     {
  220.         return $this->priceRange;
  221.     }
  222.     public function setPriceRange(array $priceRange): Store
  223.     {
  224.         $this->priceRange $priceRange;
  225.         return $this;
  226.     }
  227.     /**
  228.      * @return int
  229.      */
  230.     public function getAggregateRating()
  231.     {
  232.         return $this->aggregateRating;
  233.     }
  234.     public function setAggregateRating(int $aggregateRating): Store
  235.     {
  236.         $this->aggregateRating $aggregateRating;
  237.         return $this;
  238.     }
  239.     public function getCreatedAt()
  240.     {
  241.         return $this->createdAt;
  242.     }
  243.     /**
  244.      * @param \DateTime|\DateTimeImmutable $createdAt
  245.      */
  246.     public function setCreatedAt(?\DateTimeInterface $createdAt): Store
  247.     {
  248.         $this->createdAt $createdAt;
  249.         return $this;
  250.     }
  251.     /**
  252.      * @return Collection|Organization[]
  253.      */
  254.     public function getOrganizations(): Collection
  255.     {
  256.         return $this->organizations;
  257.     }
  258.     public function addOrganization(Organization $organization): self
  259.     {
  260.         if (!$this->organizations->contains($organization)) {
  261.             $this->organizations[] = $organization;
  262.             $organization->setStore($this);
  263.         }
  264.         return $this;
  265.     }
  266.     public function removeOrganization(Organization $organization): self
  267.     {
  268.         if ($this->organizations->contains($organization)) {
  269.             $this->organizations->removeElement($organization);
  270.             // set the owning side to null (unless already changed)
  271.             if ($organization->getStore() === $this) {
  272.                 $organization->setStore(null);
  273.             }
  274.         }
  275.         return $this;
  276.     }
  277.     public function getPrefectoralApprovalNumber(): ?string
  278.     {
  279.         return $this->prefectoralApprovalNumber;
  280.     }
  281.     public function setPrefectoralApprovalNumber(?string $prefectoralApprovalNumber): self
  282.     {
  283.         $this->prefectoralApprovalNumber $prefectoralApprovalNumber;
  284.         return $this;
  285.     }
  286.     public function getStatus(): ?string
  287.     {
  288.         return $this->status;
  289.     }
  290.     public function setStatus(?string $status): self
  291.     {
  292.         $this->status $status;
  293.         return $this;
  294.     }
  295.     public function getCedex(): ?string
  296.     {
  297.         return $this->cedex;
  298.     }
  299.     public function setCedex(?string $cedex): self
  300.     {
  301.         $this->cedex $cedex;
  302.         return $this;
  303.     }
  304.     /**
  305.      * @return Collection|DiscountCode[]
  306.      */
  307.     public function getDiscountCodes(): Collection
  308.     {
  309.         return $this->discountCodes;
  310.     }
  311.     public function addDiscountCode(DiscountCode $discountCode): self
  312.     {
  313.         if (!$this->discountCodes->contains($discountCode)) {
  314.             $this->discountCodes[] = $discountCode;
  315.             $discountCode->addStore($this);
  316.         }
  317.         return $this;
  318.     }
  319.     public function removeDiscountCode(DiscountCode $discountCode): self
  320.     {
  321.         if ($this->discountCodes->removeElement($discountCode)) {
  322.             $discountCode->removeStore($this);
  323.         }
  324.         return $this;
  325.     }
  326.     public function getSector(): ?Sector
  327.     {
  328.         return $this->sector;
  329.     }
  330.     public function setSector(?Sector $sector): self
  331.     {
  332.         $this->sector $sector;
  333.         return $this;
  334.     }
  335.     /**
  336.      * @return Collection|BAL[]
  337.      */
  338.     public function getBal(): Collection
  339.     {
  340.         return $this->bal;
  341.     }
  342.     public function addBal(BAL $bal): self
  343.     {
  344.         if (!$this->bal->contains($bal)) {
  345.             $this->bal[] = $bal;
  346.             $bal->setStore($this);
  347.         }
  348.         return $this;
  349.     }
  350.     public function removeBal(BAL $bal): self
  351.     {
  352.         if ($this->bal->removeElement($bal)) {
  353.             // set the owning side to null (unless already changed)
  354.             if ($bal->getStore() === $this) {
  355.                 $bal->setStore(null);
  356.             }
  357.         }
  358.         return $this;
  359.     }
  360.     public function getIsExportableIbml(): bool
  361.     {
  362.         return $this->isExportableIbml;
  363.     }
  364.     public function setIsExportableIbml(bool $isExportableIbml): self
  365.     {
  366.         $this->isExportableIbml $isExportableIbml;
  367.         return $this;
  368.     }
  369. }