Instead of checking the category name, check if there is a category associated with the rating.
{% if evaluation.getCategory %}
{{evaluation.category.name}}
{% endif %}
Ideally, when you delete a category associated with multiple ratings, you should remove the link between the deleted category and ratings.
, null .
yml
manyToOne:
user:
targetEntity: LB\CoreBundle\Entity\User
joinColumn:
name: user_id
referencedColumnName: id
onDelete: "SET NULL"
OnDelete "SET NULL", "CASCADE" , null , .
, . , .
$evaluations = $em->getRepository('HfAppBundle:Evaluation')->findByCategory($catId);
foreach ($evaluations as $evl) {
$evl->setCategory(null);
$em->persist($evl);
}
$em->flush();