*/ protected $casts = [ 'id' => 'integer', 'actor_id' => 'integer', 'target_actor_id' => 'integer', 'post_id' => '?string', 'activity_id' => 'string', 'type' => 'string', ]; public function getActor(): ?Actor { if ($this->actor_id === null) { throw new RuntimeException('Notification must have an actor_id before getting actor.'); } if (! $this->actor instanceof Actor) { $this->actor = (new ActorModel())->getActorById($this->actor_id); } return $this->actor; } public function getTargetActor(): ?Actor { if ($this->target_actor_id === null) { throw new RuntimeException('Notification must have a target_actor_id before getting target actor.'); } if (! $this->target_actor instanceof Actor) { $this->target_actor = (new ActorModel())->getActorById($this->target_actor_id); } return $this->target_actor; } public function getPost(): ?Post { if ($this->post_id === null) { throw new RuntimeException('Notification must have a post_id before getting post.'); } if (! $this->post instanceof Post) { $this->post = (new PostModel())->getPostById($this->post_id); } return $this->post; } }