<?php

namespace App\Models;

use App\Traits\HasCacheModel;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Str;

class Banner extends Model
{
    use HasFactory;
    use HasCacheModel;

    const STORAGE = 'banner';

    public function __construct()
    {
        $this->table = 'banner';
    }

    public function getImageAttribute($value)
    {
        if (!empty($value)) {
            if (Str::isUrl($value)) {
                return $value;
            } else {
                return asset("storage/$value");
            }
        }
        return '';
    }
}
