Вот мой объект Cheese:
Код: Выделить всё
#[ORM\Entity(repositoryClass: CheeseListingRepository::class)]
#[ApiResource]
class CheeseListing
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255)]
private ?string $title = null;
#[ORM\Column(type: Types::TEXT)]
private ?string $description = null;
#[ORM\Column]
private ?int $price = null;
#[ORM\Column]
private ?\DateTimeImmutable $createdAt = null;
#[ORM\Column]
private ?bool $isPublished = null;
public function getId(): ?int
{
return $this->id;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(string $title): self
{
$this->title = $title;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(string $description): self
{
$this->description = $description;
return $this;
}
public function setTextDescription(string $description): self
{
$this->description = nl2br($description);
return $this;
}
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->createdAt;
}
public function getCreatedAtAgo(): string
{
return Carbon::instance($this->getCreatedAt())->diffForHumans();
}
public function setCreatedAt(\DateTimeImmutable $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
}
Код: Выделить всё
{
"id": 0,
"title": "string",
"description": "string",
"createdAt": "2022-08-26T00:44:53.226Z",
"createdAtAgo": "string"
}
Код: Выделить всё
{
"title": "string",
"description": "string",
"createdAt": "2022-08-26T00:55:41.558Z"
}
Подробнее здесь: https://stackoverflow.com/questions/734 ... -dont-work
Мобильная версия