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

  1. <?php
  2. namespace App\IlaveU\ShopBundle\Entity\Store;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use App\Entity\User;
  5. use App\IlaveU\ShopBundle\Entity\Customer\Customer;
  6. use App\IlaveU\ShopBundle\Entity\Order\Order;
  7. use App\IlaveU\ShopBundle\Entity\Product\Product;
  8. use App\IlaveU\ShopBundle\Entity\Resource\Agent;
  9. use App\IlaveU\ShopBundle\Entity\Shipping\City;
  10. use App\IlaveU\ShopBundle\Entity\Shipping\CityRegion;
  11. use App\IlaveU\ShopBundle\Entity\Shipping\Shipment;
  12. use App\IlaveU\ShopBundle\Entity\Shipping\CashBox;
  13. use App\Repository\IlaveU\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. use Gedmo\Mapping\Annotation as Gedmo;
  20. #[ORM\Entity(repositoryClassStoreRepository::class)]
  21. #[ApiResource]
  22. #[Gedmo\SoftDeleteable(fieldName'deletedAt'timeAwarefalsehardDeletetrue)]
  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\Column(nullabletrue)]
  62.     private ?\DateTimeImmutable $deletedAt null;
  63.     #[ORM\OneToMany(mappedBy'store'targetEntityUser::class)]
  64.     private Collection $users;
  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->users = new ArrayCollection();
  80.     }
  81.     public function getId(): ?int
  82.     {
  83.         return $this->id;
  84.     }
  85.     public function getName(): ?string
  86.     {
  87.         return $this->name;
  88.     }
  89.     public function setName(string $name): self
  90.     {
  91.         $this->name $name;
  92.         return $this;
  93.     }
  94.     public function getCreatedAt(): ?\DateTimeInterface
  95.     {
  96.         return $this->createdAt;
  97.     }
  98.     public function setCreatedAt(?\DateTimeInterface $createdAt): self
  99.     {
  100.         $this->createdAt $createdAt;
  101.         return $this;
  102.     }
  103.     public function getDescription(): ?string
  104.     {
  105.         return $this->description;
  106.     }
  107.     public function setDescription(?string $description): self
  108.     {
  109.         $this->description $description;
  110.         return $this;
  111.     }
  112.     public function getCity(): ?City
  113.     {
  114.         return $this->city;
  115.     }
  116.     public function setCity(?City $city): self
  117.     {
  118.         $this->city $city;
  119.         return $this;
  120.     }
  121.     public function getUser(): ?User
  122.     {
  123.         return $this->user;
  124.     }
  125.     public function setUser(User $user): self
  126.     {
  127.         $this->user $user;
  128.         return $this;
  129.     }
  130.     public function getCityRegion(): ?CityRegion
  131.     {
  132.         return $this->cityRegion;
  133.     }
  134.     public function setCityRegion(?CityRegion $cityRegion): self
  135.     {
  136.         $this->cityRegion $cityRegion;
  137.         return $this;
  138.     }
  139.     public function getStoreType(): ?string
  140.     {
  141.         return $this->storeType;
  142.     }
  143.     public function setStoreType(?string $storeType): self
  144.     {
  145.         $this->storeType $storeType;
  146.         return $this;
  147.     }
  148.     /**
  149.      * @return Collection<int, CashBox>
  150.      */
  151.     public function getCashBoxes(): Collection
  152.     {
  153.         return $this->cashBoxes;
  154.     }
  155.     public function addCashBox(CashBox $cashBox): self
  156.     {
  157.         if (!$this->cashBoxes->contains($cashBox)) {
  158.             $this->cashBoxes->add($cashBox);
  159.             $cashBox->setStore($this);
  160.         }
  161.         return $this;
  162.     }
  163.     public function removeCashBox(CashBox $cashBox): self
  164.     {
  165.         if ($this->cashBoxes->removeElement($cashBox)) {
  166.             // set the owning side to null (unless already changed)
  167.             if ($cashBox->getStore() === $this) {
  168.                 $cashBox->setStore(null);
  169.             }
  170.         }
  171.         return $this;
  172.     }
  173.     /**
  174.      * @return Collection<int, Shipment>
  175.      */
  176.     public function getCollectedShipments(): Collection
  177.     {
  178.         return $this->collectedShipments;
  179.     }
  180.     public function addCollectedShipment(Shipment $collectedShipment): self
  181.     {
  182.         if (!$this->collectedShipments->contains($collectedShipment)) {
  183.             $this->collectedShipments->add($collectedShipment);
  184.             $collectedShipment->setCollectedByStore($this);
  185.         }
  186.         return $this;
  187.     }
  188.     public function removeCollectedShipment(Shipment $collectedShipment): self
  189.     {
  190.         if ($this->collectedShipments->removeElement($collectedShipment)) {
  191.             // set the owning side to null (unless already changed)
  192.             if ($collectedShipment->getCollectedByStore() === $this) {
  193.                 $collectedShipment->setCollectedByStore(null);
  194.             }
  195.         }
  196.         return $this;
  197.     }
  198.     /**
  199.      * @return Collection<int, Shipment>
  200.      */
  201.     public function getShippedShipments(): Collection
  202.     {
  203.         return $this->shippedShipments;
  204.     }
  205.     public function addShippedShipment(Shipment $shippedShipment): self
  206.     {
  207.         if (!$this->shippedShipments->contains($shippedShipment)) {
  208.             $this->shippedShipments->add($shippedShipment);
  209.             $shippedShipment->setShippedByStore($this);
  210.         }
  211.         return $this;
  212.     }
  213.     public function removeShippedShipment(Shipment $shippedShipment): self
  214.     {
  215.         if ($this->shippedShipments->removeElement($shippedShipment)) {
  216.             // set the owning side to null (unless already changed)
  217.             if ($shippedShipment->getShippedByStore() === $this) {
  218.                 $shippedShipment->setShippedByStore(null);
  219.             }
  220.         }
  221.         return $this;
  222.     }
  223.     /**
  224.      * @return Collection<int, Product>
  225.      */
  226.     public function getProducts(): Collection
  227.     {
  228.         return $this->products;
  229.     }
  230.     public function addProduct(Product $product): self
  231.     {
  232.         if (!$this->products->contains($product)) {
  233.             $this->products->add($product);
  234.             $product->setStore($this);
  235.         }
  236.         return $this;
  237.     }
  238.     public function removeProduct(Product $product): self
  239.     {
  240.         if ($this->products->removeElement($product)) {
  241.             // set the owning side to null (unless already changed)
  242.             if ($product->getStore() === $this) {
  243.                 $product->setStore(null);
  244.             }
  245.         }
  246.         return $this;
  247.     }
  248.     /**
  249.      * @return Collection<int, Order>
  250.      */
  251.     public function getOrders(): Collection
  252.     {
  253.         return $this->orders;
  254.     }
  255.     public function addOrder(Order $order): self
  256.     {
  257.         if (!$this->orders->contains($order)) {
  258.             $this->orders->add($order);
  259.             $order->setStore($this);
  260.         }
  261.         return $this;
  262.     }
  263.     public function removeOrder(Order $order): self
  264.     {
  265.         if ($this->orders->removeElement($order)) {
  266.             // set the owning side to null (unless already changed)
  267.             if ($order->getStore() === $this) {
  268.                 $order->setStore(null);
  269.             }
  270.         }
  271.         return $this;
  272.     }
  273.     /**
  274.      * @return Collection<int, Agent>
  275.      */
  276.     public function getAgents(): Collection
  277.     {
  278.         return $this->agents;
  279.     }
  280.     public function addAgent(Agent $agent): self
  281.     {
  282.         if (!$this->agents->contains($agent)) {
  283.             $this->agents->add($agent);
  284.             $agent->setStore($this);
  285.         }
  286.         return $this;
  287.     }
  288.     public function removeAgent(Agent $agent): self
  289.     {
  290.         if ($this->agents->removeElement($agent)) {
  291.             // set the owning side to null (unless already changed)
  292.             if ($agent->getStore() === $this) {
  293.                 $agent->setStore(null);
  294.             }
  295.         }
  296.         return $this;
  297.     }
  298.     /**
  299.      * @return Collection<int, Customer>
  300.      */
  301.     public function getCustomers(): Collection
  302.     {
  303.         return $this->customers;
  304.     }
  305.     public function addCustomer(Customer $customer): self
  306.     {
  307.         if (!$this->customers->contains($customer)) {
  308.             $this->customers->add($customer);
  309.             $customer->setStore($this);
  310.         }
  311.         return $this;
  312.     }
  313.     public function removeCustomer(Customer $customer): self
  314.     {
  315.         if ($this->customers->removeElement($customer)) {
  316.             // set the owning side to null (unless already changed)
  317.             if ($customer->getStore() === $this) {
  318.                 $customer->setStore(null);
  319.             }
  320.         }
  321.         return $this;
  322.     }
  323.         /**
  324.      * Get the value of deletedAt
  325.      */ 
  326.     public function getDeletedAt()
  327.     {
  328.         return $this->deletedAt;
  329.     }
  330.     /**
  331.      * Set the value of deletedAt
  332.      *
  333.      * @return  self
  334.      */ 
  335.     public function setDeletedAt($deletedAt)
  336.     {
  337.         $this->deletedAt $deletedAt;
  338.         return $this;
  339.     }
  340.     /**
  341.      * @return Collection<int, User>
  342.      */
  343.     public function getUsers(): Collection
  344.     {
  345.         return $this->users;
  346.     }
  347.     public function addUser(User $user): static
  348.     {
  349.         if (!$this->users->contains($user)) {
  350.             $this->users->add($user);
  351.             $user->setStore($this);
  352.         }
  353.         return $this;
  354.     }
  355.     public function removeUser(User $user): static
  356.     {
  357.         if ($this->users->removeElement($user)) {
  358.             // set the owning side to null (unless already changed)
  359.             if ($user->getStore() === $this) {
  360.                 $user->setStore(null);
  361.             }
  362.         }
  363.         return $this;
  364.     }
  365. }