<?php

namespace App\Models;

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

class Videos extends Model
{
    //use SoftDeletes;

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'title', 'image', 'video_file','video_height','video_width','about','age_recom', 'category_id','difficulty_id', 'download_opt','video_type','status'
    ];

    /**
     * @var array
     */
    protected $dates = ['deleted_at'];

    /**
     * Get the difficulties associated with the difficulties.
     */
    public function videoDifficulty()
    {
        return $this->hasMany('App\Models\Difficulties','id','difficulty_id');
    }

    /**
     * Get the categories associated with the categories.
     */
    public function videoCategory()
    {
        return $this->hasMany('App\Models\Categories','id','category_id');
    }

    /**
     * Get the categories associated with the categories.
     */
    public function ageRecom()
    {
        return $this->hasMany('App\Models\AgeManagement','id','age_recom');
    }

    /**
     * Get the slides associated with the slides.
     */
    public function videoSlides()
    {
        return $this->hasMany('App\Models\VideoSlides','id','video_id');
    }

    /**
     * Get the details associated with the video.
     */
    public function videoDetails()
    {
        return $this->hasMany('App\Models\VideoDetails','video_id','id')->orderBy('id', 'DESC');
    }

    public function getImgAttribute()
    {
        return url('storage/videos/thumb').'/'.$this->image;
    }

    public function getFilAttribute()
    {
        return url('storage/videos').'/'.$this->video_file;
    }


    protected $appends = ['fil', 'img'];
}
