<?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 RecoveryGallery.
 *
 * @package namespace App\Models;
 */
class Gallery extends Model implements Transformable, HasMedia
{
    use TransformableTrait;
    use InteractsWithMedia;

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


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


}
