<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

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

class Models extends Model
{
    //
    use SoftDeletes;
    protected $table='models';
    protected $fillable = [
        'image','banner','video','model_id','category_id','num','link','show'
        ];
    /**
     * Get the description of the Model.
     * @return HasMany
     */
    public function descriptions($language_id= 0) :HasMany
    {
        if ($language_id) {
            return $this->hasMany(ModelDescription::class)->where('language_id', $language_id);
        }
        return $this->hasMany(ModelDescription::class);
    }
    

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


    /**
     * Return other photos for Product
     * @return HasMany
     */
    public function photos () 
    {
        return $this->hasMany(ModelPhoto::class,'model_id');
    }
}
