<?php

namespace App\Models;

use App\Enums\ImageConversion;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class Media extends Model
{
    use HasFactory;

    protected $fillable = [
        'name',
        'path',
        'conversion_type',
        'original_url',
        'truck_id',
    ];

    protected $casts = [
        'conversion_type' => ImageConversion::class
    ];

    /**
     * Get the truck that owns the Media
     */
    public function truck(): BelongsTo
    {
        return $this->belongsTo(Truck::class);
    }
}
