Is there a way to have a single field in an entity tied to multiple different entities?
I have a "Task" entity which can be associated with either the Customer entity or Supplier entity (never both). Right now both fields are separate.
I need to use this in my TaskType form so that users can select which Customer/Supplier to associate the Task with, ideally under a single field as I plan on adding more entities that it can associate with.
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Customer", inversedBy="tasks")
*/
private $customer;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Supplier", inversedBy="tasks")
*/
private $supplier;
public function getCustomer(): ?Customer
{
return $this->customer;
}
public function setCustomer(?Customer $customer): self
{
$this->customer = $customer;
return $this;
}
public function getSupplier(): ?Supplier
...etc