Skip to content

Commit d28e034

Browse files
committed
Add jsonSerialize to News models
1 parent f215f8c commit d28e034

File tree

3 files changed

+55
-19
lines changed

3 files changed

+55
-19
lines changed

src/Models/News/Delete.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,20 @@
22

33
namespace BNETDocs\Models\News;
44

5-
class Delete extends \BNETDocs\Models\ActiveUser
5+
class Delete extends \BNETDocs\Models\ActiveUser implements \JsonSerializable
66
{
77
public bool $acl_allowed = false;
88
public ?int $id = null;
99
public ?\BNETDocs\Libraries\News\Post $news_post = null;
1010
public string $title = '';
11-
public ?\BNETDocs\Libraries\User\User $user = null;
11+
12+
public function jsonSerialize(): mixed
13+
{
14+
return \array_merge(parent::jsonSerialize(), [
15+
'acl_allowed' => $this->acl_allowed,
16+
'id' => $this->id,
17+
'news_post' => $this->news_post,
18+
'title' => $this->title,
19+
]);
20+
}
1221
}

src/Models/News/Edit.php

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,34 @@
22

33
namespace BNETDocs\Models\News;
44

5-
class Edit extends \BNETDocs\Models\ActiveUser
5+
class Edit extends \BNETDocs\Models\ActiveUser implements \JsonSerializable
66
{
7-
public bool $acl_allowed = false;
8-
public ?int $category = null;
9-
public ?array $comments = null;
10-
public ?string $content = null;
11-
public bool $markdown = false;
12-
public ?array $news_categories = null;
13-
public ?\BNETDocs\Libraries\News\Post $news_post = null;
14-
public ?int $news_post_id = null;
15-
public bool $published = false;
16-
public bool $rss_exempt = true;
17-
public ?string $title = null;
7+
public bool $acl_allowed = false;
8+
public ?int $category = null;
9+
public ?array $comments = null;
10+
public ?string $content = null;
11+
public bool $markdown = false;
12+
public ?array $news_categories = null;
13+
public ?\BNETDocs\Libraries\News\Post $news_post = null;
14+
public ?int $news_post_id = null;
15+
public bool $published = false;
16+
public bool $rss_exempt = true;
17+
public ?string $title = null;
18+
19+
public function jsonSerialize(): mixed
20+
{
21+
return \array_merge(parent::jsonSerialize(), [
22+
'acl_allowed' => $this->acl_allowed,
23+
'category' => $this->category,
24+
'comments' => $this->comments,
25+
'content' => $this->content,
26+
'markdown' => $this->markdown,
27+
'news_categories' => $this->news_categories,
28+
'news_post' => $this->news_post,
29+
'news_post_id' => $this->news_post_id,
30+
'published' => $this->published,
31+
'rss_exempt' => $this->rss_exempt,
32+
'title' => $this->title,
33+
]);
34+
}
1835
}

src/Models/News/View.php

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,20 @@
22

33
namespace BNETDocs\Models\News;
44

5-
class View extends \BNETDocs\Models\ActiveUser
5+
class View extends \BNETDocs\Models\ActiveUser implements \JsonSerializable
66
{
7-
public bool $acl_allowed = false;
8-
public ?array $comments = null;
9-
public ?\BNETDocs\Libraries\News\Post $news_post = null;
10-
public ?int $news_post_id = null;
7+
public bool $acl_allowed = false;
8+
public ?array $comments = null;
9+
public ?\BNETDocs\Libraries\News\Post $news_post = null;
10+
public ?int $news_post_id = null;
11+
12+
public function jsonSerialize(): mixed
13+
{
14+
return \array_merge(parent::jsonSerialize(), [
15+
'acl_allowed' => $this->acl_allowed,
16+
'comments' => $this->comments,
17+
'news_post' => $this->news_post,
18+
'news_post_id' => $this->news_post_id,
19+
]);
20+
}
1121
}

0 commit comments

Comments
 (0)