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\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. 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.     public function __toString()
  64.     {
  65.         return (string)$this->name;
  66.     }
  67.     public function __construct()
  68.     {
  69.         $this->user = new User();
  70.         $this->cashBoxes = new ArrayCollection();
  71.         $this->collectedShipments = new ArrayCollection();
  72.         $this->shippedShipments = new ArrayCollection();
  73.         $this->products = new ArrayCollection();
  74.         $this->orders = new ArrayCollection();
  75.         $this->agents = new ArrayCollection();
  76.         $this->customers = new ArrayCollection();
  77.     }
  78.     public function getId(): ?int
  79.     {
  80.         return $this->id;
  81.     }
  82.     public function getName(): ?string
  83.     {
  84.         return $this->name;
  85.     }
  86.     public function setName(string $name): self
  87.     {
  88.         $this->name $name;
  89.         return $this;
  90.     }
  91.     public function getCreatedAt(): ?\DateTimeInterface
  92.     {
  93.         return $this->createdAt;
  94.     }
  95.     public function setCreatedAt(?\DateTimeInterface $createdAt): self
  96.     {
  97.         $this->createdAt $createdAt;
  98.         return $this;
  99.     }
  100.     public function getDescription(): ?string
  101.     {
  102.         return $this->description;
  103.     }
  104.     public function setDescription(?string $description): self
  105.     {
  106.         $this->description $description;
  107.         return $this;
  108.     }
  109.     public function getCity(): ?City
  110.     {
  111.         return $this->city;
  112.     }
  113.     public function setCity(?City $city): self
  114.     {
  115.         $this->city $city;
  116.         return $this;
  117.     }
  118.     public function getUser(): ?User
  119.     {
  120.         return $this->user;
  121.     }
  122.     public function setUser(User $user): self
  123.     {
  124.         $this->user $user;
  125.         return $this;
  126.     }
  127.     public function getCityRegion(): ?CityRegion
  128.     {
  129.         return $this->cityRegion;
  130.     }
  131.     public function setCityRegion(?CityRegion $cityRegion): self
  132.     {
  133.         $this->cityRegion $cityRegion;
  134.         return $this;
  135.     }
  136.     public function getStoreType(): ?string
  137.     {
  138.         return $this->storeType;
  139.     }
  140.     public function setStoreType(?string $storeType): self
  141.     {
  142.         $this->storeType $storeType;
  143.         return $this;
  144.     }
  145.     /**
  146.      * @return Collection<int, CashBox>
  147.      */
  148.     public function getCashBoxes(): Collection
  149.     {
  150.         return $this->cashBoxes;
  151.     }
  152.     public function addCashBox(CashBox $cashBox): self
  153.     {
  154.         if (!$this->cashBoxes->contains($cashBox)) {
  155.             $this->cashBoxes->add($cashBox);
  156.             $cashBox->setStore($this);
  157.         }
  158.         return $this;
  159.     }
  160.     public function removeCashBox(CashBox $cashBox): self
  161.     {
  162.         if ($this->cashBoxes->removeElement($cashBox)) {
  163.             // set the owning side to null (unless already changed)
  164.             if ($cashBox->getStore() === $this) {
  165.                 $cashBox->setStore(null);
  166.             }
  167.         }
  168.         return $this;
  169.     }
  170.     /**
  171.      * @return Collection<int, Shipment>
  172.      */
  173.     public function getCollectedShipments(): Collection
  174.     {
  175.         return $this->collectedShipments;
  176.     }
  177.     public function addCollectedShipment(Shipment $collectedShipment): self
  178.     {
  179.         if (!$this->collectedShipments->contains($collectedShipment)) {
  180.             $this->collectedShipments->add($collectedShipment);
  181.             $collectedShipment->setCollectedByStore($this);
  182.         }
  183.         return $this;
  184.     }
  185.     public function removeCollectedShipment(Shipment $collectedShipment): self
  186.     {
  187.         if ($this->collectedShipments->removeElement($collectedShipment)) {
  188.             // set the owning side to null (unless already changed)
  189.             if ($collectedShipment->getCollectedByStore() === $this) {
  190.                 $collectedShipment->setCollectedByStore(null);
  191.             }
  192.         }
  193.         return $this;
  194.     }
  195.     /**
  196.      * @return Collection<int, Shipment>
  197.      */
  198.     public function getShippedShipments(): Collection
  199.     {
  200.         return $this->shippedShipments;
  201.     }
  202.     public function addShippedShipment(Shipment $shippedShipment): self
  203.     {
  204.         if (!$this->shippedShipments->contains($shippedShipment)) {
  205.             $this->shippedShipments->add($shippedShipment);
  206.             $shippedShipment->setShippedByStore($this);
  207.         }
  208.         return $this;
  209.     }
  210.     public function removeShippedShipment(Shipment $shippedShipment): self
  211.     {
  212.         if ($this->shippedShipments->removeElement($shippedShipment)) {
  213.             // set the owning side to null (unless already changed)
  214.             if ($shippedShipment->getShippedByStore() === $this) {
  215.                 $shippedShipment->setShippedByStore(null);
  216.             }
  217.         }
  218.         return $this;
  219.     }
  220.     /**
  221.      * @return Collection<int, Product>
  222.      */
  223.     public function getProducts(): Collection
  224.     {
  225.         return $this->products;
  226.     }
  227.     public function addProduct(Product $product): self
  228.     {
  229.         if (!$this->products->contains($product)) {
  230.             $this->products->add($product);
  231.             $product->setStore($this);
  232.         }
  233.         return $this;
  234.     }
  235.     public function removeProduct(Product $product): self
  236.     {
  237.         if ($this->products->removeElement($product)) {
  238.             // set the owning side to null (unless already changed)
  239.             if ($product->getStore() === $this) {
  240.                 $product->setStore(null);
  241.             }
  242.         }
  243.         return $this;
  244.     }
  245.     /**
  246.      * @return Collection<int, Order>
  247.      */
  248.     public function getOrders(): Collection
  249.     {
  250.         return $this->orders;
  251.     }
  252.     public function addOrder(Order $order): self
  253.     {
  254.         if (!$this->orders->contains($order)) {
  255.             $this->orders->add($order);
  256.             $order->setStore($this);
  257.         }
  258.         return $this;
  259.     }
  260.     public function removeOrder(Order $order): self
  261.     {
  262.         if ($this->orders->removeElement($order)) {
  263.             // set the owning side to null (unless already changed)
  264.             if ($order->getStore() === $this) {
  265.                 $order->setStore(null);
  266.             }
  267.         }
  268.         return $this;
  269.     }
  270.     /**
  271.      * @return Collection<int, Agent>
  272.      */
  273.     public function getAgents(): Collection
  274.     {
  275.         return $this->agents;
  276.     }
  277.     public function addAgent(Agent $agent): self
  278.     {
  279.         if (!$this->agents->contains($agent)) {
  280.             $this->agents->add($agent);
  281.             $agent->setStore($this);
  282.         }
  283.         return $this;
  284.     }
  285.     public function removeAgent(Agent $agent): self
  286.     {
  287.         if ($this->agents->removeElement($agent)) {
  288.             // set the owning side to null (unless already changed)
  289.             if ($agent->getStore() === $this) {
  290.                 $agent->setStore(null);
  291.             }
  292.         }
  293.         return $this;
  294.     }
  295.     /**
  296.      * @return Collection<int, Customer>
  297.      */
  298.     public function getCustomers(): Collection
  299.     {
  300.         return $this->customers;
  301.     }
  302.     public function addCustomer(Customer $customer): self
  303.     {
  304.         if (!$this->customers->contains($customer)) {
  305.             $this->customers->add($customer);
  306.             $customer->setStore($this);
  307.         }
  308.         return $this;
  309.     }
  310.     public function removeCustomer(Customer $customer): self
  311.     {
  312.         if ($this->customers->removeElement($customer)) {
  313.             // set the owning side to null (unless already changed)
  314.             if ($customer->getStore() === $this) {
  315.                 $customer->setStore(null);
  316.             }
  317.         }
  318.         return $this;
  319.     }
  320.         /**
  321.      * Get the value of deletedAt
  322.      */ 
  323.     public function getDeletedAt()
  324.     {
  325.         return $this->deletedAt;
  326.     }
  327.     /**
  328.      * Set the value of deletedAt
  329.      *
  330.      * @return  self
  331.      */ 
  332.     public function setDeletedAt($deletedAt)
  333.     {
  334.         $this->deletedAt $deletedAt;
  335.         return $this;
  336.     }
  337. }