<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class ProductFeature extends Model
{
    public $timestamps = false;

    protected $fillable = [
        'image',
        'product_id',
    ];


    public function details()
    {
        return $this->hasMany(ProductDetail::class);
    }

    public function descriptions($language_id= null)
    {

        if ($language_id) {
            $data = $this->hasMany(ProductFeatureDescription::class)->where('language_id', $language_id)->first();
            if(!$data){
                $data = $this->hasMany(ProductFeatureDescription::class)->first();
            }

            return $data;
        }
        $data = $this->hasMany(ProductFeatureDescription::class)->where('language_id', currentLanguage()['id'])->first();
        return $data;
    }
}
