2025-01-23 00:45:59 +01:00

62 lines
1.3 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Models;
use Carbon\CarbonInterface;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
/**
* @property int $id
* @property string $title
* @property string $content
* @property ?Category $category
* @property int $category_id
* @property CarbonInterface $created_at
* @property CarbonInterface $updated_at
*/
class Post extends Model
{
/** @use HasFactory<\Database\Factories\PostFactory> */
use HasFactory;
/**
* The attributes that are mass assignable.
*
* @var list<string>
*/
protected $fillable = [
'title',
'content',
'category_id',
];
/**
* @return BelongsTo<Category, $this>
*/
public function category()
{
return $this->belongsTo(Category::class);
}
/**
* @return BelongsToMany<Tag, $this>
*/
public function tags()
{
return $this->belongsToMany(Tag::class);
}
/**
* @return \Illuminate\Database\Eloquent\Relations\MorphMany<Comment, $this>
*/
public function comments()
{
return $this->morphMany(Comment::class, 'commentable');
}
}