*/ protected $casts = [ // phpcs:ignore 'user_id' => 'integer', 'is_meeting' => 'boolean', 'is_pinned' => 'boolean', 'is_important' => 'boolean', ]; /** @var array Default attributes */ protected $attributes = [ // phpcs:ignore 'is_meeting' => false, 'is_pinned' => false, 'is_important' => false, ]; /** @var array */ protected $fillable = [ // phpcs:ignore 'title', 'text', 'is_meeting', 'is_pinned', 'is_important', 'user_id', ]; public function comments(): HasMany { return $this->hasMany(NewsComment::class) ->orderBy('created_at'); } 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); } }