<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Slide extends Model
{
    protected $primaryKey = 'sl_id';

    public function translations() {
        return $this->hasMany("App\SlideTranslation", 'sl_id', 'sl_id');
    }

    public function translation($lang) {
        return $this->hasOne("App\SlideTranslation", 'sl_id', 'sl_id')->where('lang', '=', $lang)->first();
    }

    public function ctranslation() {
        return $this->hasOne("App\SlideTranslation", 'sl_id', 'sl_id')->where('lang', '=', app()->getLocale());
    }
}
