<?php

namespace App\Models;

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

class Imageable extends Model
{
    use HasFactory;

    protected $fillable = [
        'image_id',
        'imageable_id',
        'imageable_type',
        'type',
        'role',
        'sort_order',
    ];

    // Polymorphic relation to the owning model
    public function imageable()
    {
        return $this->morphTo();
    }

    // Relation to the actual Image model
    public function image()
    {
        return $this->belongsTo(Image::class);
    }
}
