<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Prettus\Repository\Contracts\Transformable;
use Prettus\Repository\Traits\TransformableTrait;
use Spatie\MediaLibrary\HasMedia;
use Spatie\MediaLibrary\InteractsWithMedia;

/**
 * Class HomePageSlider.
 *
 * @package namespace App\Models;
 */
class HomePageSlider extends Model implements Transformable, HasMedia
{
    use TransformableTrait;
    use InteractsWithMedia;

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'title',
        'btn_text',
        'description',
        'decuraton_text',
    ];

    public function sliderVideo($mediaType)
    {
        $media = $this->getMedia($mediaType)->first();
        if ($media) {
            return $media->getUrl();
        }
        return asset('upload/No-Image.png');
    }

}
