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

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