add order
This commit is contained in:
parent
7663f684a4
commit
1dc5306967
37 changed files with 1060 additions and 113 deletions
|
@ -3,6 +3,8 @@
|
|||
namespace App\Entity;
|
||||
|
||||
use App\Repository\FoodVendorRepository;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Bridge\Doctrine\IdGenerator\UlidGenerator;
|
||||
use Symfony\Bridge\Doctrine\Types\UlidType;
|
||||
|
@ -20,6 +22,17 @@ class FoodVendor
|
|||
#[ORM\Column(length: 50)]
|
||||
private string|null $name = null;
|
||||
|
||||
/**
|
||||
* @var Collection<int, FoodOrder>
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: FoodOrder::class, mappedBy: 'foodVendor', orphanRemoval: true)]
|
||||
private Collection $foodOrders;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->foodOrders = new ArrayCollection;
|
||||
}
|
||||
|
||||
public function getId(): Ulid|null
|
||||
{
|
||||
return $this->id;
|
||||
|
@ -36,4 +49,32 @@ class FoodVendor
|
|||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, FoodOrder>
|
||||
*/
|
||||
public function getFoodOrders(): Collection
|
||||
{
|
||||
return $this->foodOrders;
|
||||
}
|
||||
|
||||
public function addFoodOrder(FoodOrder $foodOrder): static
|
||||
{
|
||||
if (! $this->foodOrders->contains($foodOrder)) {
|
||||
$this->foodOrders->add($foodOrder);
|
||||
$foodOrder->setFoodVendor($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeFoodOrder(FoodOrder $foodOrder): static
|
||||
{
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($this->foodOrders->removeElement($foodOrder) && $foodOrder->getFoodVendor() === $this) {
|
||||
$foodOrder->setFoodVendor(null);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue