Comment.php 690 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. namespace internship\bo;
  3. use n2n\persistence\orm\attribute\ManyToOne;
  4. use n2n\reflection\ObjectAdapter;
  5. class Comment extends ObjectAdapter implements \JsonSerializable {
  6. public int $id;
  7. public string $author;
  8. public string $text;
  9. #[ManyToOne(Article::class)]
  10. public ?Article $article = null;
  11. // function __construct(Article $article) {
  12. // $this->article = $article;
  13. // }
  14. function basicJsonSerialize() {
  15. return [
  16. 'id' => $this->id,
  17. 'author' => $this->author,
  18. 'text' => $this->text
  19. ];
  20. }
  21. public function jsonSerialize(): mixed {
  22. $basicJson = $this->basicJsonSerialize();
  23. // $basicJson['articleId'] = $this->article->id;
  24. return $basicJson;
  25. }
  26. }