我目前拥有这个实体,我想在我的 JSON 中显示我的属性
firedDate
即使该值为空也可以。/**
* @ApiResource(normalizationContext={"groups"={"employee"}})
* @ApiFilter(DateFilter::class, properties={"dateProperty": DateFilter::INCLUDE_NULL_BEFORE_AND_AFTER})
* @ORM\Table(name="employee")
*/
class Employee
{
// ...
/**
* @ORM\Column(type="datetime", nullable=true)
* @Groups({"employee"})
*/
private $firedDate;
public function getFiredDate(): ?\DateTimeInterface
{
return $this->firedDate;
}
// ...
}
目前,当值为null
时,它不会在响应中显示。