*/ public function cover(): HasOne { return $this->hasOne(Image::class, 'image_id'); } /** * Get the description as a cleaned/handled HTML string. */ public function descriptionHtml(bool $raw = false): string { $html = $this->description_html ?: '

' . nl2br(e($this->description)) . '

'; if ($raw) { return $html; } return HtmlContentFilter::removeScriptsFromHtmlString($html); } /** * Update the description from HTML code. * Optionally takes plaintext to use for the model also. */ public function setDescriptionHtml(string $html, string|null $plaintext = null): void { $this->description_html = $html; if ($plaintext !== null) { $this->description = $plaintext; } if (empty($html) && !empty($plaintext)) { $this->description_html = $this->descriptionHtml(); } } }