This commit is contained in:
lubiana 2025-06-29 19:26:29 +02:00
parent bbc56a9af7
commit 1f9562d36b
Signed by: lubiana
SSH key fingerprint: SHA256:vW1EA0fRR3Fw+dD/sM0K+x3Il2gSry6YRYHqOeQwrfk
13 changed files with 525 additions and 507 deletions

View file

@ -16,19 +16,17 @@ use Symfony\Component\Validator\Constraints\Length;
use function mb_strlen;
#[ORM\Entity(repositoryClass: FoodVendorRepository::class)]
#[ApiResource]
#[ORM\Entity(repositoryClass: FoodVendorRepository::class)]
class FoodVendor
{
#[ORM\Column(length: 50)]
/**
* String of emojis (max 30 characters)
*/
#[Groups(['food_order:latest', 'food_vendor:read'])]
private string|null $name = null;
#[ORM\Column(length: 50, nullable: true, options: [
'default' => '',
])]
#[Groups(['food_order:latest', 'food_vendor:read'])]
private string|null $phone = null;
#[Length(max: 10)]
#[ORM\Column(length: 30, nullable: true)]
private string|null $emojis = null;
/**
* @var Collection<int, FoodOrder>
@ -42,24 +40,26 @@ class FoodVendor
#[ORM\OneToMany(targetEntity: MenuItem::class, mappedBy: 'foodVendor', orphanRemoval: true)]
private Collection $menuItems;
#[ORM\Column(length: 255, nullable: true)]
#[Groups(['food_order:latest'])]
#[ORM\Column(length: 255, nullable: true)]
private string|null $menuLink = null;
/**
* String of emojis (max 30 characters)
*/
#[ORM\Column(length: 30, nullable: true)]
#[Groups(['food_order:latest', 'food_vendor:read'])]
#[Length(max: 10)]
private string|null $emojis = null;
#[ORM\Column(length: 50)]
private string|null $name = null;
#[Groups(['food_order:latest', 'food_vendor:read'])]
#[ORM\Column(length: 50, nullable: true, options: [
'default' => '',
])]
private string|null $phone = null;
public function __construct(
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
#[Groups(['food_order:latest'])]
#[ORM\Column(type: UlidType::NAME, unique: true)]
#[ORM\CustomIdGenerator(class: UlidGenerator::class)]
#[Groups(['food_order:latest'])]
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
#[ORM\Id]
private Ulid|null $id = new Ulid
) {
$this->id ??= new Ulid;
@ -67,31 +67,6 @@ class FoodVendor
$this->menuItems = new ArrayCollection;
}
public function getId(): Ulid|null
{
return $this->id;
}
public function getName(): string|null
{
return $this->name;
}
public function setName(string $name): static
{
$this->name = $name;
return $this;
}
/**
* @return Collection<int, FoodOrder>
*/
public function getFoodOrders(): Collection
{
return $this->foodOrders;
}
public function addFoodOrder(FoodOrder $foodOrder): static
{
if (! $this->foodOrders->contains($foodOrder)) {
@ -102,16 +77,34 @@ class FoodVendor
return $this;
}
public function removeFoodOrder(FoodOrder $foodOrder): static
public function addMenuItem(MenuItem $menuItem): static
{
// set the owning side to null (unless already changed)
if ($this->foodOrders->removeElement($foodOrder)) {
$foodOrder->setFoodVendor(null);
if (! $this->menuItems->contains($menuItem)) {
$this->menuItems->add($menuItem);
$menuItem->setFoodVendor($this);
}
return $this;
}
public function getEmojis(): string|null
{
return $this->emojis;
}
/**
* @return Collection<int, FoodOrder>
*/
public function getFoodOrders(): Collection
{
return $this->foodOrders;
}
public function getId(): Ulid|null
{
return $this->id;
}
/**
* @return Collection<int, MenuItem>
*/
@ -125,11 +118,26 @@ class FoodVendor
);
}
public function addMenuItem(MenuItem $menuItem): static
public function getMenuLink(): string|null
{
if (! $this->menuItems->contains($menuItem)) {
$this->menuItems->add($menuItem);
$menuItem->setFoodVendor($this);
return $this->menuLink;
}
public function getName(): string|null
{
return $this->name;
}
public function getPhone(): string|null
{
return $this->phone;
}
public function removeFoodOrder(FoodOrder $foodOrder): static
{
// set the owning side to null (unless already changed)
if ($this->foodOrders->removeElement($foodOrder)) {
$foodOrder->setFoodVendor(null);
}
return $this;
@ -145,34 +153,6 @@ class FoodVendor
return $this;
}
public function getMenuLink(): string|null
{
return $this->menuLink;
}
public function setMenuLink(string|null $menuLink): static
{
$this->menuLink = $menuLink;
return $this;
}
public function getPhone(): string|null
{
return $this->phone;
}
public function setPhone(string|null $phone): static
{
$this->phone = $phone;
return $this;
}
public function getEmojis(): string|null
{
return $this->emojis;
}
public function setEmojis(string|null $emojis): static
{
if ($emojis !== null && mb_strlen($emojis) > 30) {
@ -182,4 +162,24 @@ class FoodVendor
$this->emojis = $emojis;
return $this;
}
public function setMenuLink(string|null $menuLink): static
{
$this->menuLink = $menuLink;
return $this;
}
public function setName(string $name): static
{
$this->name = $name;
return $this;
}
public function setPhone(string|null $phone): static
{
$this->phone = $phone;
return $this;
}
}