wip: article AI polish, category SEO fields, cover generator, membership plan seeder
This commit is contained in:
@@ -11,6 +11,10 @@ class Category extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'description',
|
||||
'intro',
|
||||
'keywords',
|
||||
'cover_path',
|
||||
'display_order',
|
||||
'articles_count',
|
||||
];
|
||||
@@ -27,4 +31,23 @@ class Category extends Model
|
||||
{
|
||||
return $this->hasMany(Article::class);
|
||||
}
|
||||
|
||||
public function publicUrl(): string
|
||||
{
|
||||
return url('/category-'.$this->id.'.shtml');
|
||||
}
|
||||
|
||||
public function coverUrl(): ?string
|
||||
{
|
||||
$path = trim((string) $this->cover_path);
|
||||
if ($path === '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (str_starts_with($path, 'http://') || str_starts_with($path, 'https://')) {
|
||||
return $path;
|
||||
}
|
||||
|
||||
return asset(ltrim($path, '/'));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user