src/Flexy/ShopBundle/Entity/Store/Store.php line 26

  1. <?php
  2. namespace App\Flexy\ShopBundle\Entity\Store;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use App\Entity\User;
  5. use App\Flexy\ShopBundle\Entity\Customer\Customer;
  6. use App\Flexy\ShopBundle\Entity\Customer\Visit;
  7. use App\Flexy\ShopBundle\Entity\Order\CashBoxOrder;
  8. use App\Flexy\ShopBundle\Entity\Order\Order;
  9. use App\Flexy\ShopBundle\Entity\Product\Product;
  10. use App\Flexy\ShopBundle\Entity\Resource\Agent;
  11. use App\Flexy\ShopBundle\Entity\Shipping\City;
  12. use App\Flexy\ShopBundle\Entity\Shipping\CityRegion;
  13. use App\Flexy\ShopBundle\Entity\Shipping\Shipment;
  14. use App\Flexy\ShopBundle\Entity\Shipping\CashBox;
  15. use App\Repository\Flexy\ShopBundle\Entity\Store\StoreRepository;
  16. use Doctrine\Common\Collections\ArrayCollection;
  17. use Doctrine\Common\Collections\Collection;
  18. use Doctrine\DBAL\Types\Types;
  19. use Doctrine\ORM\Mapping as ORM;
  20. use Symfony\Component\Validator\Constraints as Assert;
  21. #[ORM\Entity(repositoryClassStoreRepository::class)]
  22. #[ApiResource]
  23. class Store
  24. {
  25.     #[ORM\Id]
  26.     #[ORM\GeneratedValue]
  27.     #[ORM\Column]
  28.     private ?int $id null;
  29.     #[ORM\Column(length255)]
  30.     private ?string $name null;
  31.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  32.     private ?\DateTimeInterface $createdAt null;
  33.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  34.     private ?string $description null;
  35.     #[ORM\ManyToOne(inversedBy'stores')]
  36.     #[ORM\JoinColumn(nullablefalse)]
  37.     private ?City $city null;
  38.     #[ORM\OneToOne(cascade: ['persist''remove'])]
  39.     #[ORM\JoinColumn(nullablefalse)]
  40.     #[Assert\Valid]
  41.     private ?User $user null;
  42.     #[ORM\ManyToOne(inversedBy'stores')]
  43.     #[ORM\JoinColumn(nullabletrue)]
  44.     private ?CityRegion $cityRegion null;
  45.     #[ORM\Column(length255nullabletrue)]
  46.     private ?string $storeType null;
  47.     #[ORM\OneToMany(mappedBy'store'targetEntityCashBox::class)]
  48.     private Collection $cashBoxes;
  49.     #[ORM\OneToMany(mappedBy'collectedByStore'targetEntityShipment::class)]
  50.     private Collection $collectedShipments;
  51.     #[ORM\OneToMany(mappedBy'shippedByStore'targetEntityShipment::class)]
  52.     private Collection $shippedShipments;
  53.     #[ORM\OneToMany(mappedBy'store'targetEntityProduct::class)]
  54.     private Collection $products;
  55.     #[ORM\OneToMany(mappedBy'store'targetEntityOrder::class)]
  56.     private Collection $orders;
  57.     #[ORM\OneToMany(mappedBy'store'targetEntityAgent::class)]
  58.     private Collection $agents;
  59.     #[ORM\OneToMany(mappedBy'store'targetEntityCustomer::class)]
  60.     private Collection $customers;
  61.     #[ORM\OneToMany(mappedBy'store'targetEntityCashBoxOrder::class)]
  62.     private Collection $cashBoxOrders;
  63.     #[ORM\OneToMany(mappedBy'store'targetEntityVisit::class)]
  64.     private Collection $visits;
  65.     public function __toString()
  66.     {
  67.         return (string)$this->name;
  68.     }
  69.     public function __construct()
  70.     {
  71.         $this->user = new User();
  72.         $this->cashBoxes = new ArrayCollection();
  73.         $this->collectedShipments = new ArrayCollection();
  74.         $this->shippedShipments = new ArrayCollection();
  75.         $this->products = new ArrayCollection();
  76.         $this->orders = new ArrayCollection();
  77.         $this->agents = new ArrayCollection();
  78.         $this->customers = new ArrayCollection();
  79.         $this->cashBoxOrders = new ArrayCollection();
  80.         $this->visits = new ArrayCollection();
  81.     }
  82.     public function getId(): ?int
  83.     {
  84.         return $this->id;
  85.     }
  86.     public function getName(): ?string
  87.     {
  88.         return $this->name;
  89.     }
  90.     public function setName(string $name): self
  91.     {
  92.         $this->name $name;
  93.         return $this;
  94.     }
  95.     public function getCreatedAt(): ?\DateTimeInterface
  96.     {
  97.         return $this->createdAt;
  98.     }
  99.     public function setCreatedAt(?\DateTimeInterface $createdAt): self
  100.     {
  101.         $this->createdAt $createdAt;
  102.         return $this;
  103.     }
  104.     public function getDescription(): ?string
  105.     {
  106.         return $this->description;
  107.     }
  108.     public function setDescription(?string $description): self
  109.     {
  110.         $this->description $description;
  111.         return $this;
  112.     }
  113.     public function getCity(): ?City
  114.     {
  115.         return $this->city;
  116.     }
  117.     public function setCity(?City $city): self
  118.     {
  119.         $this->city $city;
  120.         return $this;
  121.     }
  122.     public function getUser(): ?User
  123.     {
  124.         return $this->user;
  125.     }
  126.     public function setUser(User $user): self
  127.     {
  128.         $this->user $user;
  129.         return $this;
  130.     }
  131.     public function getCityRegion(): ?CityRegion
  132.     {
  133.         return $this->cityRegion;
  134.     }
  135.     public function setCityRegion(?CityRegion $cityRegion): self
  136.     {
  137.         $this->cityRegion $cityRegion;
  138.         return $this;
  139.     }
  140.     public function getStoreType(): ?string
  141.     {
  142.         return $this->storeType;
  143.     }
  144.     public function setStoreType(?string $storeType): self
  145.     {
  146.         $this->storeType $storeType;
  147.         return $this;
  148.     }
  149.     /**
  150.      * @return Collection<int, CashBox>
  151.      */
  152.     public function getCashBoxes(): Collection
  153.     {
  154.         return $this->cashBoxes;
  155.     }
  156.     public function addCashBox(CashBox $cashBox): self
  157.     {
  158.         if (!$this->cashBoxes->contains($cashBox)) {
  159.             $this->cashBoxes->add($cashBox);
  160.             $cashBox->setStore($this);
  161.         }
  162.         return $this;
  163.     }
  164.     public function removeCashBox(CashBox $cashBox): self
  165.     {
  166.         if ($this->cashBoxes->removeElement($cashBox)) {
  167.             // set the owning side to null (unless already changed)
  168.             if ($cashBox->getStore() === $this) {
  169.                 $cashBox->setStore(null);
  170.             }
  171.         }
  172.         return $this;
  173.     }
  174.     /**
  175.      * @return Collection<int, Shipment>
  176.      */
  177.     public function getCollectedShipments(): Collection
  178.     {
  179.         return $this->collectedShipments;
  180.     }
  181.     public function addCollectedShipment(Shipment $collectedShipment): self
  182.     {
  183.         if (!$this->collectedShipments->contains($collectedShipment)) {
  184.             $this->collectedShipments->add($collectedShipment);
  185.             $collectedShipment->setCollectedByStore($this);
  186.         }
  187.         return $this;
  188.     }
  189.     public function removeCollectedShipment(Shipment $collectedShipment): self
  190.     {
  191.         if ($this->collectedShipments->removeElement($collectedShipment)) {
  192.             // set the owning side to null (unless already changed)
  193.             if ($collectedShipment->getCollectedByStore() === $this) {
  194.                 $collectedShipment->setCollectedByStore(null);
  195.             }
  196.         }
  197.         return $this;
  198.     }
  199.     /**
  200.      * @return Collection<int, Shipment>
  201.      */
  202.     public function getShippedShipments(): Collection
  203.     {
  204.         return $this->shippedShipments;
  205.     }
  206.     public function addShippedShipment(Shipment $shippedShipment): self
  207.     {
  208.         if (!$this->shippedShipments->contains($shippedShipment)) {
  209.             $this->shippedShipments->add($shippedShipment);
  210.             $shippedShipment->setShippedByStore($this);
  211.         }
  212.         return $this;
  213.     }
  214.     public function removeShippedShipment(Shipment $shippedShipment): self
  215.     {
  216.         if ($this->shippedShipments->removeElement($shippedShipment)) {
  217.             // set the owning side to null (unless already changed)
  218.             if ($shippedShipment->getShippedByStore() === $this) {
  219.                 $shippedShipment->setShippedByStore(null);
  220.             }
  221.         }
  222.         return $this;
  223.     }
  224.     /**
  225.      * @return Collection<int, Product>
  226.      */
  227.     public function getProducts(): Collection
  228.     {
  229.         return $this->products;
  230.     }
  231.     public function addProduct(Product $product): self
  232.     {
  233.         if (!$this->products->contains($product)) {
  234.             $this->products->add($product);
  235.             $product->setStore($this);
  236.         }
  237.         return $this;
  238.     }
  239.     public function removeProduct(Product $product): self
  240.     {
  241.         if ($this->products->removeElement($product)) {
  242.             // set the owning side to null (unless already changed)
  243.             if ($product->getStore() === $this) {
  244.                 $product->setStore(null);
  245.             }
  246.         }
  247.         return $this;
  248.     }
  249.     /**
  250.      * @return Collection<int, Order>
  251.      */
  252.     public function getOrders(): Collection
  253.     {
  254.         return $this->orders;
  255.     }
  256.     public function addOrder(Order $order): self
  257.     {
  258.         if (!$this->orders->contains($order)) {
  259.             $this->orders->add($order);
  260.             $order->setStore($this);
  261.         }
  262.         return $this;
  263.     }
  264.     public function removeOrder(Order $order): self
  265.     {
  266.         if ($this->orders->removeElement($order)) {
  267.             // set the owning side to null (unless already changed)
  268.             if ($order->getStore() === $this) {
  269.                 $order->setStore(null);
  270.             }
  271.         }
  272.         return $this;
  273.     }
  274.     /**
  275.      * @return Collection<int, Agent>
  276.      */
  277.     public function getAgents(): Collection
  278.     {
  279.         return $this->agents;
  280.     }
  281.     public function addAgent(Agent $agent): self
  282.     {
  283.         if (!$this->agents->contains($agent)) {
  284.             $this->agents->add($agent);
  285.             $agent->setStore($this);
  286.         }
  287.         return $this;
  288.     }
  289.     public function removeAgent(Agent $agent): self
  290.     {
  291.         if ($this->agents->removeElement($agent)) {
  292.             // set the owning side to null (unless already changed)
  293.             if ($agent->getStore() === $this) {
  294.                 $agent->setStore(null);
  295.             }
  296.         }
  297.         return $this;
  298.     }
  299.     /**
  300.      * @return Collection<int, Customer>
  301.      */
  302.     public function getCustomers(): Collection
  303.     {
  304.         return $this->customers;
  305.     }
  306.     public function addCustomer(Customer $customer): self
  307.     {
  308.         if (!$this->customers->contains($customer)) {
  309.             $this->customers->add($customer);
  310.             $customer->setStore($this);
  311.         }
  312.         return $this;
  313.     }
  314.     public function removeCustomer(Customer $customer): self
  315.     {
  316.         if ($this->customers->removeElement($customer)) {
  317.             // set the owning side to null (unless already changed)
  318.             if ($customer->getStore() === $this) {
  319.                 $customer->setStore(null);
  320.             }
  321.         }
  322.         return $this;
  323.     }
  324.     /**
  325.      * @return Collection<int, CashBoxOrder>
  326.      */
  327.     public function getCashBoxOrders(): Collection
  328.     {
  329.         return $this->cashBoxOrders;
  330.     }
  331.     public function addCashBoxOrder(CashBoxOrder $cashBoxOrder): self
  332.     {
  333.         if (!$this->cashBoxOrders->contains($cashBoxOrder)) {
  334.             $this->cashBoxOrders->add($cashBoxOrder);
  335.             $cashBoxOrder->setStore($this);
  336.         }
  337.         return $this;
  338.     }
  339.     public function removeCashBoxOrder(CashBoxOrder $cashBoxOrder): self
  340.     {
  341.         if ($this->cashBoxOrders->removeElement($cashBoxOrder)) {
  342.             // set the owning side to null (unless already changed)
  343.             if ($cashBoxOrder->getStore() === $this) {
  344.                 $cashBoxOrder->setStore(null);
  345.             }
  346.         }
  347.         return $this;
  348.     }
  349.     /**
  350.      * @return Collection<int, Visit>
  351.      */
  352.     public function getVisits(): Collection
  353.     {
  354.         return $this->visits;
  355.     }
  356.     public function addVisit(Visit $visit): static
  357.     {
  358.         if (!$this->visits->contains($visit)) {
  359.             $this->visits->add($visit);
  360.             $visit->setStore($this);
  361.         }
  362.         return $this;
  363.     }
  364.     public function removeVisit(Visit $visit): static
  365.     {
  366.         if ($this->visits->removeElement($visit)) {
  367.             // set the owning side to null (unless already changed)
  368.             if ($visit->getStore() === $this) {
  369.                 $visit->setStore(null);
  370.             }
  371.         }
  372.         return $this;
  373.     }
  374. }