comment moderation improvments
This commit is contained in:
@@ -16,6 +16,19 @@ class Comment extends Model
|
||||
'user_id',
|
||||
'product_id',
|
||||
'body',
|
||||
'status',
|
||||
'moderated_by',
|
||||
'moderated_at',
|
||||
'moderation_note',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast.
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
protected $casts = [
|
||||
'moderated_at' => 'datetime',
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -33,4 +46,36 @@ class Comment extends Model
|
||||
{
|
||||
return $this->belongsTo(Product::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the moderator who moderated the comment.
|
||||
*/
|
||||
public function moderator(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'moderated_by');
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if comment is pending moderation.
|
||||
*/
|
||||
public function isPending(): bool
|
||||
{
|
||||
return $this->status === 'pending';
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if comment is approved.
|
||||
*/
|
||||
public function isApproved(): bool
|
||||
{
|
||||
return $this->status === 'approved';
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if comment is rejected.
|
||||
*/
|
||||
public function isRejected(): bool
|
||||
{
|
||||
return $this->status === 'rejected';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user