<?php

namespace App\Models;

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

class ImageIndex extends Model
{
    use HasUlids;

    protected $table = 'images_index';

    protected $fillable = [
        'user_id', 'hash', 'file_path', 'mime_type', 'size_bytes',
        'width', 'height', 'table_ref', 'record_id',
    ];

    protected $casts = [
        'size_bytes' => 'integer',
        'width' => 'integer',
        'height' => 'integer',
    ];

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