Answer the question
In order to leave comments, you need to log in
How to search in a table on a ManyToMany field?
2 tables with related fields Many to Many relationship
class Records
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $title;
/**
* @ORM\Column(type="string", length=40)
*/
private $link;
/**
* @ORM\Column(type="text")
*/
private $description;
/**
* @ORM\ManyToOne(targetEntity=Versions::class, inversedBy="records")
* @ORM\JoinColumn(nullable=false)
*/
private $version;
/**
* @ORM\Column(type="boolean")
*/
private $visible;
/**
* @ORM\ManyToMany(targetEntity=Mods::class, inversedBy="records")
*/
private $mods;
public function __construct()
{
$this->mods = new ArrayCollection();
}
}
class Mods
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $name;
/**
* @ORM\ManyToMany(targetEntity=Records::class, mappedBy="mods")
*/
private $records;
public function __construct()
{
$this->records = new ArrayCollection();
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question