现在我有很多实体:
#[ORM\Column(type: 'datetime')]
#[Groups(['article_category:output'])]
/**
* @Timestampable(on="create")
*/
private \DateTime $createdAt;
public function getCreatedAt(): \DateTime
{
return $this->createdAt;
}
字符串
我想把它放在Trait里面。但是每个实体都有自己的标准化组(比如'article_category:output')。我如何让这个字段在API平台上总是可用?
1条答案
按热度按时间zwghvu4y1#
我们所做的:
在你的特质中使用一个组,例如
timestampable
字符串
然后,每当你想公开时间戳时,将它们添加到你的配置中(你可以向一个操作添加多个组)
型