<?php

namespace App\Models;

use App\Models\Concerns\BelongsToCompany;
use App\Support\PublicMedia;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class GalleryItem extends Model
{
    use HasFactory, SoftDeletes, BelongsToCompany;

    protected $fillable = [
        'company_id', 'title', 'description', 'image_path',
        'sort_order', 'is_public',
    ];

    protected function casts(): array
    {
        return [
            'is_public' => 'boolean',
        ];
    }

    public function imageUrl(): string
    {
        return PublicMedia::url($this->image_path) ?? '';
    }
}
