Use the JoinColumn annotation on your ManyToOne relation:
/**
* @ORM\ManyToOne(targetEntity="Package", inversedBy="users")
* @ORM\JoinColumn(name="package_id", referencedColumnName="id", nullable=false)
*/
private $package;
The ManyToOne itself cannot be nullable, because it doesn't relate to a specific column. The JoinColumn on the other hand identifies the column in the database. Thus, you can use "normal" attributes like nullable or unique!
Only
@ORM\JoinColumn(nullable=false)
is required
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With