<?php
namespace App\Entity;
use App\Entity\traits\base64Field;
use App\Entity\traits\Timestapable;
use App\Repository\ShopRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: ShopRepository::class)]
class Shop
{
use Timestapable;
use base64Field;
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\ManyToOne(inversedBy: 'shops')]
private ?user $owner = null;
#[ORM\Column(length: 255)]
private ?string $name = null;
#[ORM\Column(length: 255)]
private ?string $slogan = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $slug = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $logo_url = null;
#[ORM\Column(length: 255)]
private ?string $locality = null;
#[ORM\Column(length: 255)]
private ?string $city = null;
#[ORM\Column(length: 255)]
private ?string $town = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $lat = null;
#[ORM\Column(length: 255)]
private ?string $lon = null;
#[ORM\OneToMany(mappedBy: 'shop', targetEntity: Product::class)]
private Collection $products;
public function __construct()
{
$this->products = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getOwner(): ?user
{
return $this->owner;
}
public function setOwner(?user $owner): self
{
$this->owner = $owner;
return $this;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getSlogan(): ?string
{
return $this->slogan;
}
public function setSlogan(string $slogan): self
{
$this->slogan = $slogan;
return $this;
}
public function getSlug(): ?string
{
return $this->slug;
}
public function setSlug(?string $slug): self
{
$this->slug = $slug;
return $this;
}
public function getLogoUrl(): ?string
{
return $this->logo_url;
}
public function setLogoUrl(?string $logo_url): self
{
$this->logo_url = $logo_url;
return $this;
}
public function getLocality(): ?string
{
return $this->locality;
}
public function setLocality(string $locality): self
{
$this->locality = $locality;
return $this;
}
public function getCity(): ?string
{
return $this->city;
}
public function setCity(string $city): self
{
$this->city = $city;
return $this;
}
public function getTown(): ?string
{
return $this->town;
}
public function setTown(string $town): self
{
$this->town = $town;
return $this;
}
public function getLat(): ?string
{
return $this->lat;
}
public function setLat(?string $lat): self
{
$this->lat = $lat;
return $this;
}
public function getLon(): ?string
{
return $this->lon;
}
public function setLon(string $lon): self
{
$this->lon = $lon;
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->setShop($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->getShop() === $this) {
$product->setShop(null);
}
}
return $this;
}
}