55 lines
1.1 KiB
PHP
55 lines
1.1 KiB
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;
|
|
|
|
class Comment extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
public const STATUS_PENDING = 'pending';
|
|
public const STATUS_PUBLISHED = 'published';
|
|
public const STATUS_SPAM = 'spam';
|
|
public const STATUS_REJECTED = 'rejected';
|
|
|
|
protected $fillable = [
|
|
'post_id',
|
|
'user_id',
|
|
'author_name',
|
|
'author_email',
|
|
'author_url',
|
|
'content',
|
|
'ip',
|
|
'status',
|
|
'ai_review',
|
|
];
|
|
|
|
protected $casts = [
|
|
'ai_review' => 'array',
|
|
'created_at' => 'datetime',
|
|
];
|
|
|
|
public $timestamps = false;
|
|
|
|
public function post(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Post::class);
|
|
}
|
|
|
|
public function user(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class);
|
|
}
|
|
|
|
public function isVisible(): bool
|
|
{
|
|
return $this->status === self::STATUS_PUBLISHED;
|
|
}
|
|
}
|