43 lines
858 B
PHP
43 lines
858 B
PHP
<?php
|
|||
|
|
|
||
|
|
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 TaskComment extends Model
|
||
|
|
{
|
||
|
|
use HasFactory, SoftDeletes;
|
||
|
|
|
||
|
|
public const AUTHOR_TYPES = ['user', 'ai', 'system'];
|
||
|
|
|
||
|
|
protected $fillable = [
|
||
|
|
'task_id',
|
||
|
|
'body',
|
||
|
|
'author_type',
|
||
|
|
'author_name',
|
||
|
|
];
|
||
|
|
|
||
|
|
public function task(): BelongsTo
|
||
|
|
{
|
||
|
|
return $this->belongsTo(Task::class);
|
||
|
|
}
|
||
|
|
|
||
|
|
public function isFromAI(): bool
|
||
|
|
{
|
||
|
|
return $this->author_type === 'ai';
|
||
|
|
}
|
||
|
|
|
||
|
|
public function isFromUser(): bool
|
||
|
|
{
|
||
|
|
return $this->author_type === 'user';
|
||
|
|
}
|
||
|
|
|
||
|
|
public function isSystem(): bool
|
||
|
|
{
|
||
|
|
return $this->author_type === 'system';
|
||
|
|
}
|
||
|
|
}
|