'boolean', 'is_pinned' => 'boolean', ]; /** @var array */ protected $fillable = [ 'title', 'text', 'is_meeting', 'is_pinned', 'user_id', ]; /** * @return HasMany */ public function comments(): HasMany { return $this->hasMany(NewsComment::class) ->orderBy('created_at'); } /** * @param bool $showMore * @return string */ public function text(bool $showMore = true): string { if ($showMore || !Str::contains($this->text, 'more')) { // Remove more tag return preg_replace('/(.*)\[\s*more\s*\](.*)/is', '$1$2', $this->text); } // Only show text before more tag $text = preg_replace('/(.*)(\s*\[\s*more\s*\].*)/is', '$1', $this->text); return rtrim($text); } }