aiblog/app/Models/Comment.php
2024-11-17 11:30:01 +08:00

33 lines
No EOL
661 B
PHP

<?php
declare(strict_types=1);
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
class Comment extends Model
{
use HasFactory, SoftDeletes;
protected $fillable = [
'content',
'post_id',
'author_id',
];
protected $dates = ['deleted_at'];
public function post(): BelongsTo
{
return $this->belongsTo(Post::class);
}
public function author(): BelongsTo
{
return $this->belongsTo(User::class, 'author_id');
}
}