<?php

namespace App\Models;

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

class FileUpload extends Model
{
    public const STATUS_PENDING = 'pending';

    public const STATUS_ANALYZED = 'analyzed';

    public const STATUS_FAILED = 'failed';

    protected $fillable = [
        'user_id',
        'original_name',
        'mime',
        'size_bytes',
        'disk',
        'path',
        'status',
        'analysis_summary',
        'analysis_json',
    ];

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

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