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

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