<?php

namespace App;

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

/**
 * @property mixed product_id
 */
class Product extends Model
{
    use SoftDeletes;

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

    public function descriptions()
    {
        return $this->hasMany(ProductDescription::class);
    }

    public function currentDescription() :HasOne
    {
        return $this->hasOne(ProductDescription::class)->where('language_id', currentLanguage()->id);
    }

    public function products()
    {
        return $this->hasMany(Product::class, 'product_id', 'id');
    }

    public function product()
    {
        return $this->belongsTo(Product::class, 'product_id', 'id');
    }
}
