Files
ai-web/app/Models/Guide.php

54 lines
1.2 KiB
PHP
Raw Normal View History

2026-02-11 17:28:36 +08:00
<?php
declare(strict_types=1);
namespace App\Models;
use App\Enums\EntityStatus;
use App\Models\Concerns\HasPublicationScope;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
class Guide extends Model
{
use HasFactory;
use HasPublicationScope;
protected $fillable = [
'category_id',
'title',
'slug',
'excerpt',
'body',
'difficulty',
'status',
'seo_title',
'seo_description',
'h1',
'canonical_url',
'published_at',
];
protected function casts(): array
{
return [
'published_at' => 'datetime',
'status' => EntityStatus::class,
];
}
public function category(): BelongsTo
{
return $this->belongsTo(Category::class);
}
public function tags(): BelongsToMany
{
return $this->belongsToMany(Tag::class, 'entity_tag_maps', 'entity_id', 'tag_id')
->wherePivot('entity_type', self::class)
->withTimestamps();
}
}