2023-03-27 17:58:05 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Models\Forms\AI;
|
|
|
|
|
|
|
|
use App\Jobs\Form\GenerateAiForm;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
|
|
|
class AiFormCompletion extends Model
|
|
|
|
{
|
|
|
|
use HasFactory;
|
|
|
|
|
2024-02-23 10:54:12 +00:00
|
|
|
public const STATUS_PENDING = 'pending';
|
|
|
|
|
|
|
|
public const STATUS_PROCESSING = 'processing';
|
|
|
|
|
|
|
|
public const STATUS_COMPLETED = 'completed';
|
|
|
|
|
|
|
|
public const STATUS_FAILED = 'failed';
|
2023-03-27 17:58:05 +00:00
|
|
|
|
|
|
|
protected $table = 'ai_form_completions';
|
|
|
|
|
|
|
|
protected $fillable = [
|
|
|
|
'form_prompt',
|
|
|
|
'status',
|
|
|
|
'result',
|
2024-02-23 10:54:12 +00:00
|
|
|
'ip',
|
2023-03-27 17:58:05 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
protected $attributes = [
|
2024-02-23 10:54:12 +00:00
|
|
|
'status' => self::STATUS_PENDING,
|
2023-03-27 17:58:05 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
protected static function booted()
|
|
|
|
{
|
|
|
|
// Dispatch completion job on creation
|
|
|
|
static::created(function (self $completion) {
|
|
|
|
GenerateAiForm::dispatch($completion);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|