<?php

namespace App\Models;


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

class Group extends Model
{
    //use soft delete
    use SoftDeletes;

    protected $fillable = [
        'foodics_id', 'parent_foodics_id' ,'image', 'body','order'
    ];

    public function getNameAttribute()
    {
        return $this->currentDescription->name;
    }
    /**
     * Get current description of the the Room
     * @return HasOne
     */
    public function currentDescription() :HasOne
    {
        return $this->hasOne(GroupDescription::class)->where('language_id', currentLanguage()->id);
    }

}
