Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
/**
* @copyright 2020 Podlibre
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
* @link https://castopod.org/
*/
namespace App\Entities;
use App\Models\EpisodeModel;
class Note extends \ActivityPub\Entities\Note
{
/**
* @var \App\Entities\Episode|null
*/
protected $episode;
protected $casts = [
'id' => 'string',
'uri' => 'string',
'actor_id' => 'integer',
'in_reply_to_id' => '?string',
'reblog_of_id' => '?string',
'episode_id' => '?integer',
'message' => 'string',
'message_html' => 'string',
'favourites_count' => 'integer',
'reblogs_count' => 'integer',
'replies_count' => 'integer',
'created_by' => 'integer',
];
/**
* Returns the note's attached episode
*
* @return \App\Entities\Episode
*/
public function getEpisode()
{
if (empty($this->episode_id)) {
throw new \RuntimeException(
'Note must have an episode_id before getting episode.',
);
}
if (empty($this->episode)) {
$this->episode = (new EpisodeModel())->getEpisodeById(
$this->episode_id,
);
}
return $this->episode;
}
}