<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

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

class FlavorType extends Model
{
    use SoftDeletes;

    protected $fillable = ['image'];


    /**
     * Get description of current language of The Category
     * @return HasOne
     */
    public function currentDescription() :HasOne
    {
        return $this->hasOne(FlavorTypeDescription::class)->where('language_id', currentLanguage()->id);
    }

    /**
     * Get the description of the category.
     * @param int $language_id
     * @return HasMany
     */
    public function descriptions($language_id= 0) :HasMany
    {
        if ($language_id) {
            return $this->hasMany(FlavorTypeDescription::class)->where('language_id', $language_id);
        }
        return $this->hasMany(FlavorTypeDescription::class);
    }
}
