<?php

namespace App\Models;

use App\Modules\Users\Models\User;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

/**
 * @property int $id
 * @property int $user_id
 * @property string $prompt
 * @property string|null $style
 * @property string $status
 * @property string|null $provider
 * @property string|null $external_id
 * @property string|null $result_url
 * @property array<string, mixed>|null $meta
 */
class AiImageJob extends Model
{
    public const STATUS_QUEUED = 'queued';

    public const STATUS_FAILED = 'failed';

    public const STATUS_COMPLETED = 'completed';

    protected $fillable = [
        'user_id',
        'prompt',
        'style',
        'status',
        'provider',
        'external_id',
        'result_url',
        'meta',
    ];

    /**
     * @return array<string, string>
     */
    protected function casts(): array
    {
        return [
            'meta' => 'array',
        ];
    }

    /** @return BelongsTo<User, AiImageJob> */
    public function user(): BelongsTo
    {
        return $this->belongsTo(User::class);
    }
}
