opnform/app/Models/Forms/AI/AiFormCompletion.php

42 lines
874 B
PHP
Raw Normal View History

<?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';
protected $table = 'ai_form_completions';
protected $fillable = [
'form_prompt',
'status',
'result',
2024-02-23 10:54:12 +00:00
'ip',
];
protected $attributes = [
2024-02-23 10:54:12 +00:00
'status' => self::STATUS_PENDING,
];
protected static function booted()
{
// Dispatch completion job on creation
static::created(function (self $completion) {
GenerateAiForm::dispatch($completion);
});
}
}