|
|
@ -10,6 +10,7 @@ use Illuminate\Database\Eloquent\Collection;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
use Illuminate\Database\Query\Builder as QueryBuilder;
|
|
|
|
use Illuminate\Database\Query\Builder as QueryBuilder;
|
|
|
|
|
|
|
|
use Illuminate\Support\Str;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @property int $id
|
|
|
|
* @property int $id
|
|
|
@ -21,7 +22,7 @@ use Illuminate\Database\Query\Builder as QueryBuilder;
|
|
|
|
* @property Carbon|null $updated_at
|
|
|
|
* @property Carbon|null $updated_at
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @property-read Collection|NewsComment[] $comments
|
|
|
|
* @property-read Collection|NewsComment[] $comments
|
|
|
|
* @property-read int|null $comments_count
|
|
|
|
* @property-read int|null $comments_count
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @method static QueryBuilder|LogEntry[] whereId($value)
|
|
|
|
* @method static QueryBuilder|LogEntry[] whereId($value)
|
|
|
|
* @method static QueryBuilder|LogEntry[] whereTitle($value)
|
|
|
|
* @method static QueryBuilder|LogEntry[] whereTitle($value)
|
|
|
@ -42,7 +43,7 @@ class News extends BaseModel
|
|
|
|
/** @var array */
|
|
|
|
/** @var array */
|
|
|
|
protected $casts = [
|
|
|
|
protected $casts = [
|
|
|
|
'is_meeting' => 'boolean',
|
|
|
|
'is_meeting' => 'boolean',
|
|
|
|
'is_pinned' => 'boolean',
|
|
|
|
'is_pinned' => 'boolean',
|
|
|
|
];
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
/** @var array */
|
|
|
|
/** @var array */
|
|
|
@ -62,4 +63,20 @@ class News extends BaseModel
|
|
|
|
return $this->hasMany(NewsComment::class)
|
|
|
|
return $this->hasMany(NewsComment::class)
|
|
|
|
->orderBy('created_at');
|
|
|
|
->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);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|