feat: implement AI styling foundation and billing scope rework
This commit is contained in:
103
app/Models/AiEditRequest.php
Normal file
103
app/Models/AiEditRequest.php
Normal file
@@ -0,0 +1,103 @@
|
||||
<?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\Relations\HasMany;
|
||||
|
||||
class AiEditRequest extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
public const STATUS_QUEUED = 'queued';
|
||||
|
||||
public const STATUS_PROCESSING = 'processing';
|
||||
|
||||
public const STATUS_SUCCEEDED = 'succeeded';
|
||||
|
||||
public const STATUS_FAILED = 'failed';
|
||||
|
||||
public const STATUS_BLOCKED = 'blocked';
|
||||
|
||||
public const STATUS_CANCELED = 'canceled';
|
||||
|
||||
protected $fillable = [
|
||||
'tenant_id',
|
||||
'event_id',
|
||||
'photo_id',
|
||||
'style_id',
|
||||
'requested_by_user_id',
|
||||
'provider',
|
||||
'provider_model',
|
||||
'status',
|
||||
'safety_state',
|
||||
'prompt',
|
||||
'negative_prompt',
|
||||
'input_image_path',
|
||||
'requested_by_device_id',
|
||||
'requested_by_session_id',
|
||||
'idempotency_key',
|
||||
'safety_reasons',
|
||||
'failure_code',
|
||||
'failure_message',
|
||||
'queued_at',
|
||||
'started_at',
|
||||
'completed_at',
|
||||
'expires_at',
|
||||
'metadata',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'safety_reasons' => 'array',
|
||||
'metadata' => 'array',
|
||||
'queued_at' => 'datetime',
|
||||
'started_at' => 'datetime',
|
||||
'completed_at' => 'datetime',
|
||||
'expires_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
public function tenant(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Tenant::class);
|
||||
}
|
||||
|
||||
public function event(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Event::class);
|
||||
}
|
||||
|
||||
public function photo(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Photo::class);
|
||||
}
|
||||
|
||||
public function style(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(AiStyle::class, 'style_id');
|
||||
}
|
||||
|
||||
public function requestedBy(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'requested_by_user_id');
|
||||
}
|
||||
|
||||
public function outputs(): HasMany
|
||||
{
|
||||
return $this->hasMany(AiEditOutput::class, 'request_id');
|
||||
}
|
||||
|
||||
public function providerRuns(): HasMany
|
||||
{
|
||||
return $this->hasMany(AiProviderRun::class, 'request_id');
|
||||
}
|
||||
|
||||
public function usageLedgers(): HasMany
|
||||
{
|
||||
return $this->hasMany(AiUsageLedger::class, 'request_id');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user