| 1234567891011121314151617181920212223242526272829303132333435363738 |
- <?php
- namespace internship\bo;
- use n2n\persistence\orm\attribute\ManyToOne;
- use n2n\reflection\ObjectAdapter;
- class Comment extends ObjectAdapter implements \JsonSerializable {
- public int $id;
- public string $author;
- public string $text;
- #[ManyToOne(Article::class)]
- public ?Article $article = null;
- // function __construct(Article $article) {
- // $this->article = $article;
- // }
- function basicJsonSerialize() {
- return [
- 'id' => $this->id,
- 'author' => $this->author,
- 'text' => $this->text
- ];
- }
- public function jsonSerialize(): mixed {
- $basicJson = $this->basicJsonSerialize();
- // $basicJson['articleId'] = $this->article->id;
- return $basicJson;
- }
- }
|