<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class AccessRoute extends Model
{
    use HasFactory;


    protected $fillable = [
        'name_route',
        'name_table',
        'name_model_ar',
        'name_model_en',
        'icon_model',
        'show_count',
        'parent_id',
    ];

    // get name translation
    public function getNameModelAttribute()
    {
        return $this->attributes['name_model_' . app()->getLocale()];
    } // end getNameAttribute


    public function childs()
    {
        return $this->hasMany(AccessRoute::class, 'parent_id', 'id');
    }
}
