<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;

class Slider extends Model
{
     //use soft delete
    use SoftDeletes;

    protected $fillable = [
       
       'link','image','cost'
    ];
    public function descriptions($language_id= null)
    {
        if ($language_id) {
            $data = $this->hasMany(SliderDescription::class)->where('language_id', $language_id)->first();
            if(!$data){
                $data = $this->hasMany(SliderDescription::class)->first();
            }
            
            return $data;
        }
        return $this->hasMany(SliderDescription::class);
    }
}
