payload() + [ 'title' => __('api.notifications.moderation_threshold_title'), 'body' => __('api.notifications.moderation_threshold_body', [ 'type' => $this->targetLabel(), 'count' => $this->moderationCase->reports_count, ]), 'targetTitle' => $this->targetTitle(), ]; } private function payload(): array { return [ 'type' => 'moderation_case_threshold', 'moderationCaseId' => $this->moderationCase->getKey(), 'reportableType' => $this->targetType(), 'reportableId' => $this->moderationCase->caseable_id, 'reportsCount' => $this->moderationCase->reports_count, ]; } private function targetType(): string { return match ($this->moderationCase->caseable_type) { MealPosts::class => 'meal_post', User::class => 'user', default => 'unknown', }; } private function targetLabel(): string { return match ($this->moderationCase->caseable_type) { MealPosts::class => __('api.reports.targets.meal_post'), User::class => __('api.reports.targets.user'), default => __('api.reports.targets.unknown'), }; } private function targetTitle(): string { $target = $this->moderationCase->caseable; return match (true) { $target instanceof MealPosts => $target->title, $target instanceof User => $target->name, default => (string) $this->moderationCase->caseable_id, }; } }