<?php

namespace App\Models;

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

class EventMediaAsset extends Model
{
    use HasFactory;

    protected $fillable = [
        'event_id',
        'media_storage_target_id',
        'photo_id',
        'variant',
        'disk',
        'path',
        'size_bytes',
        'checksum',
        'mime_type',
        'status',
        'processed_at',
        'archived_at',
        'restored_at',
        'error_message',
        'meta',
    ];

    protected $casts = [
        'size_bytes' => 'integer',
        'processed_at' => 'datetime',
        'archived_at' => 'datetime',
        'restored_at' => 'datetime',
        'meta' => 'array',
    ];

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

    public function storageTarget(): BelongsTo
    {
        return $this->belongsTo(MediaStorageTarget::class, 'media_storage_target_id');
    }

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

