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