<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Storage;
use Spatie\Translatable\HasTranslations;

class Banner extends Model
{
    use HasTranslations;

    //
    protected $guarded  = ["id"];
    public $translatable = ['title', 'content', 'img_alt'];

    public $appends = [
        "img_url_link", "mobile_img_link"
    ];

    protected function imgUrlLink(): Attribute
    {
        return Attribute::make(
            get: fn ($value) => is_null($this->img_url) ? null :Storage::url($this->img_url),
        );
    }

    protected function mobileImgLink(): Attribute
    {
        return Attribute::make(
            get: fn ($value) => is_null($this->mobile_img) ? null :Storage::url($this->mobile_img),
        );
    }
}
