wip: article AI polish, category SEO fields, cover generator, membership plan seeder
This commit is contained in:
@@ -6,6 +6,7 @@ namespace App\Models;
|
||||
|
||||
use App\Domain\Blog\ContentFormat;
|
||||
use App\Domain\Blog\ContentRenderer;
|
||||
use App\Domain\Media\ArticleCoverService;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
@@ -33,6 +34,7 @@ class Article extends Model
|
||||
'read_password',
|
||||
'ai_summary',
|
||||
'ai_suggestions',
|
||||
'ai_polished_content',
|
||||
'legacy_attachments',
|
||||
'cover_disk',
|
||||
'cover_path',
|
||||
@@ -61,6 +63,11 @@ class Article extends Model
|
||||
return $this->cover_status === 'ready' && filled($this->cover_path);
|
||||
}
|
||||
|
||||
public function coverUrl(): ?string
|
||||
{
|
||||
return app(ArticleCoverService::class)->publicUrl($this);
|
||||
}
|
||||
|
||||
protected function contentFormat(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
|
||||
@@ -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, '/'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,4 +66,18 @@ class Comment extends Model
|
||||
{
|
||||
return $this->moderation_status === self::STATUS_APPROVED;
|
||||
}
|
||||
|
||||
public function websiteHref(): ?string
|
||||
{
|
||||
$url = trim((string) $this->url);
|
||||
if ($url === '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (! preg_match('#^https?://#i', $url)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user