This commit is contained in:
cjd
2026-02-05 22:22:10 +08:00
parent fef9fe0c31
commit bf3a2e6971
273 changed files with 30605 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Comment extends Model
{
use HasFactory;
protected $fillable = [
'target_type',
'target_id',
'nickname',
'email',
'content',
'status',
'like_count',
'reply_content',
'replied_at',
'ip',
'user_agent',
];
protected $casts = [
'replied_at' => 'datetime',
];
public function product()
{
return $this->belongsTo(Product::class, 'target_id')
->where('target_type', 'product');
}
public function article()
{
return $this->belongsTo(Article::class, 'target_id')
->where('target_type', 'article');
}
}