<?php

declare(strict_types=1);

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

/**
 * App\Models\ArtworkVersion
 *
 * Represents a single immutable snapshot of an artwork file.
 * Only one version per artwork is marked is_current = true at a time.
 */
class ArtworkVersion extends Model
{
    protected $table = 'artwork_versions';

    protected $fillable = [
        'artwork_id',
        'version_number',
        'file_path',
        'file_hash',
        'width',
        'height',
        'file_size',
        'change_note',
        'snapshot_json',
        'is_current',
    ];

    protected $casts = [
        'is_current'  => 'boolean',
        'version_number' => 'integer',
        'width'       => 'integer',
        'height'      => 'integer',
        'file_size'   => 'integer',
        'snapshot_json' => 'array',
    ];

    public function artwork(): BelongsTo
    {
        return $this->belongsTo(Artwork::class);
    }
}
