1

我正在使用 Mitchell van Wijngaarden 的 Doctrine 解决方案(https://github.com/mitchellvanw/laravel-doctrine/wiki/Soft-Deleting)和 Laravel 4。

我已经设置了软删除,但仍然让软删除的实体出现在搜索结果中。例如,以下查询:

$group_instructions = $this->entityManager->getRepository('GroupInstruction')->findBy(array('librarian'=>$user));

即使“deleted_at”字段已填充时间戳,此查询也会返回 GroupInstruction 类的所有实体。我的印象是所有软删除的项目都会被隐藏。有没有人有这方面的经验?

4

1 回答 1

-1

为了激活软删除,您需要为 EntityManager 过滤器启用它。我不确定这是如何在 laravel 上完成的,但在学说上是这样完成的:

$em->getFilters()->enable('soft-deletable');

在此处查看更多信息: https ://github.com/Atlantic18/DoctrineExtensions/blob/master/doc/softdeleteable.md#setup-and-autoloading

于 2014-11-16T08:15:18.003 回答