Files
2026-09-01 09:22:30 -03:00

88 lines
2.1 KiB
PHP
Executable File

<?php
declare(strict_types=1);
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
class PromptGeneration extends Model
{
use \Illuminate\Database\Eloquent\SoftDeletes;
/**
* The attributes that are mass assignable.
*
* @var list<string>
*/
protected $fillable = [
'project_id',
'user_id',
'provider_id',
'model_id',
'generated_prompt',
'input_data',
'output_data',
'tokens_used',
'generation_time',
'status',
];
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
'input_data' => 'array',
'output_data' => 'array',
'tokens_used' => 'integer',
'generation_time' => 'decimal:3',
];
}
/**
* Get the prompt project that owns the generation.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\App\Models\PromptProject, \App\Models\PromptGeneration>
*/
public function project(): BelongsTo
{
return $this->belongsTo(PromptProject::class);
}
/**
* Get the user that owns the generation.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\App\Models\User, \App\Models\PromptGeneration>
*/
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
/**
* Get the AI provider for the generation.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\App\Models\AiProvider, \App\Models\PromptGeneration>
*/
public function provider(): BelongsTo
{
return $this->belongsTo(AiProvider::class);
}
/**
* Get the AI model for the generation.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\App\Models\AiModel, \App\Models\PromptGeneration>
*/
public function model(): BelongsTo
{
return $this->belongsTo(AiModel::class);
}
}