<?php

namespace App;

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

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

    protected $fillable = ['video', 'image', 'type', 'video_category_id'];


    /**
     * Return current descriptions of article
     * @return HasMany
     */
    public function currentDescription() : HasOne
    {
        return $this->hasOne(VideoDescription::class)->where('language_id', currentLanguage()->id);
    }

    /**
     * Return descriptions for video
     * @return HasMany
     */
    public function descriptions() :HasMany
    {
        return $this->hasMany(VideoDescription::class);
    }

    /**
     * Return category for video
     * @return BelongsTo
     */
    public function category() :BelongsTo
    {
        return $this->belongsTo(VideoCategory::class);
    }

}
