<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class Slider extends Model
{
    use SoftDeletes;

    protected $fillable = ['image', 'url'];

    public static function withDescription()
    {
        return self::orderBy('sliders.id', 'DESC')
            ->join('slider_descriptions as sd', 'sd.slider_id', 'sliders.id')
            ->where('sd.language_id', currentLanguage()->id)
            ->select(['sliders.*', 'sd.*'])->cursor();
    }
}
