src/Flexy/ShopBundle/Entity/Store/Store.php line 26
<?php
namespace App\Flexy\ShopBundle\Entity\Store;
use ApiPlatform\Metadata\ApiResource;
use App\Entity\User;
use App\Flexy\ShopBundle\Entity\Customer\Customer;
use App\Flexy\ShopBundle\Entity\Order\Order;
use App\Flexy\ShopBundle\Entity\Product\Product;
use App\Flexy\ShopBundle\Entity\Resource\Agent;
use App\Flexy\ShopBundle\Entity\Shipping\City;
use App\Flexy\ShopBundle\Entity\Shipping\CityRegion;
use App\Flexy\ShopBundle\Entity\Shipping\Shipment;
use App\Flexy\ShopBundle\Entity\Shipping\CashBox;
use App\Repository\Flexy\ShopBundle\Entity\Store\StoreRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Gedmo\Mapping\Annotation as Gedmo;
#[ORM\Entity(repositoryClass: StoreRepository::class)]
#[ApiResource]
#[Gedmo\SoftDeleteable(fieldName: 'deletedAt', timeAware: false, hardDelete: true)]
class Store
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255)]
private ?string $name = null;
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $createdAt = null;
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $description = null;
#[ORM\ManyToOne(inversedBy: 'stores')]
#[ORM\JoinColumn(nullable: false)]
private ?City $city = null;
#[ORM\OneToOne(cascade: ['persist', 'remove'])]
#[ORM\JoinColumn(nullable: false)]
#[Assert\Valid]
private ?User $user = null;
#[ORM\ManyToOne(inversedBy: 'stores')]
#[ORM\JoinColumn(nullable: true)]
private ?CityRegion $cityRegion = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $storeType = null;
#[ORM\OneToMany(mappedBy: 'store', targetEntity: CashBox::class)]
private Collection $cashBoxes;
#[ORM\OneToMany(mappedBy: 'collectedByStore', targetEntity: Shipment::class)]
private Collection $collectedShipments;
#[ORM\OneToMany(mappedBy: 'shippedByStore', targetEntity: Shipment::class)]
private Collection $shippedShipments;
#[ORM\OneToMany(mappedBy: 'store', targetEntity: Product::class)]
private Collection $products;
#[ORM\OneToMany(mappedBy: 'store', targetEntity: Order::class)]
private Collection $orders;
#[ORM\OneToMany(mappedBy: 'store', targetEntity: Agent::class)]
private Collection $agents;
#[ORM\OneToMany(mappedBy: 'store', targetEntity: Customer::class)]
private Collection $customers;
#[ORM\Column(nullable: true)]
private ?\DateTimeImmutable $deletedAt = null;
public function __toString()
{
return (string)$this->name;
}
public function __construct()
{
$this->user = new User();
$this->cashBoxes = new ArrayCollection();
$this->collectedShipments = new ArrayCollection();
$this->shippedShipments = new ArrayCollection();
$this->products = new ArrayCollection();
$this->orders = new ArrayCollection();
$this->agents = new ArrayCollection();
$this->customers = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(?\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getCity(): ?City
{
return $this->city;
}
public function setCity(?City $city): self
{
$this->city = $city;
return $this;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(User $user): self
{
$this->user = $user;
return $this;
}
public function getCityRegion(): ?CityRegion
{
return $this->cityRegion;
}
public function setCityRegion(?CityRegion $cityRegion): self
{
$this->cityRegion = $cityRegion;
return $this;
}
public function getStoreType(): ?string
{
return $this->storeType;
}
public function setStoreType(?string $storeType): self
{
$this->storeType = $storeType;
return $this;
}
/**
* @return Collection<int, CashBox>
*/
public function getCashBoxes(): Collection
{
return $this->cashBoxes;
}
public function addCashBox(CashBox $cashBox): self
{
if (!$this->cashBoxes->contains($cashBox)) {
$this->cashBoxes->add($cashBox);
$cashBox->setStore($this);
}
return $this;
}
public function removeCashBox(CashBox $cashBox): self
{
if ($this->cashBoxes->removeElement($cashBox)) {
// set the owning side to null (unless already changed)
if ($cashBox->getStore() === $this) {
$cashBox->setStore(null);
}
}
return $this;
}
/**
* @return Collection<int, Shipment>
*/
public function getCollectedShipments(): Collection
{
return $this->collectedShipments;
}
public function addCollectedShipment(Shipment $collectedShipment): self
{
if (!$this->collectedShipments->contains($collectedShipment)) {
$this->collectedShipments->add($collectedShipment);
$collectedShipment->setCollectedByStore($this);
}
return $this;
}
public function removeCollectedShipment(Shipment $collectedShipment): self
{
if ($this->collectedShipments->removeElement($collectedShipment)) {
// set the owning side to null (unless already changed)
if ($collectedShipment->getCollectedByStore() === $this) {
$collectedShipment->setCollectedByStore(null);
}
}
return $this;
}
/**
* @return Collection<int, Shipment>
*/
public function getShippedShipments(): Collection
{
return $this->shippedShipments;
}
public function addShippedShipment(Shipment $shippedShipment): self
{
if (!$this->shippedShipments->contains($shippedShipment)) {
$this->shippedShipments->add($shippedShipment);
$shippedShipment->setShippedByStore($this);
}
return $this;
}
public function removeShippedShipment(Shipment $shippedShipment): self
{
if ($this->shippedShipments->removeElement($shippedShipment)) {
// set the owning side to null (unless already changed)
if ($shippedShipment->getShippedByStore() === $this) {
$shippedShipment->setShippedByStore(null);
}
}
return $this;
}
/**
* @return Collection<int, Product>
*/
public function getProducts(): Collection
{
return $this->products;
}
public function addProduct(Product $product): self
{
if (!$this->products->contains($product)) {
$this->products->add($product);
$product->setStore($this);
}
return $this;
}
public function removeProduct(Product $product): self
{
if ($this->products->removeElement($product)) {
// set the owning side to null (unless already changed)
if ($product->getStore() === $this) {
$product->setStore(null);
}
}
return $this;
}
/**
* @return Collection<int, Order>
*/
public function getOrders(): Collection
{
return $this->orders;
}
public function addOrder(Order $order): self
{
if (!$this->orders->contains($order)) {
$this->orders->add($order);
$order->setStore($this);
}
return $this;
}
public function removeOrder(Order $order): self
{
if ($this->orders->removeElement($order)) {
// set the owning side to null (unless already changed)
if ($order->getStore() === $this) {
$order->setStore(null);
}
}
return $this;
}
/**
* @return Collection<int, Agent>
*/
public function getAgents(): Collection
{
return $this->agents;
}
public function addAgent(Agent $agent): self
{
if (!$this->agents->contains($agent)) {
$this->agents->add($agent);
$agent->setStore($this);
}
return $this;
}
public function removeAgent(Agent $agent): self
{
if ($this->agents->removeElement($agent)) {
// set the owning side to null (unless already changed)
if ($agent->getStore() === $this) {
$agent->setStore(null);
}
}
return $this;
}
/**
* @return Collection<int, Customer>
*/
public function getCustomers(): Collection
{
return $this->customers;
}
public function addCustomer(Customer $customer): self
{
if (!$this->customers->contains($customer)) {
$this->customers->add($customer);
$customer->setStore($this);
}
return $this;
}
public function removeCustomer(Customer $customer): self
{
if ($this->customers->removeElement($customer)) {
// set the owning side to null (unless already changed)
if ($customer->getStore() === $this) {
$customer->setStore(null);
}
}
return $this;
}
/**
* Get the value of deletedAt
*/
public function getDeletedAt()
{
return $this->deletedAt;
}
/**
* Set the value of deletedAt
*
* @return self
*/
public function setDeletedAt($deletedAt)
{
$this->deletedAt = $deletedAt;
return $this;
}
}