status == 1 ? ' Active ' : 'Inactive';
}
protected function createdBy(): Attribute
{
return Attribute::make(
get: fn ($value) => User::find($value) ? User::find($value)->name : '',
);
}
protected function updatedBy(): Attribute
{
return Attribute::make(
get: fn ($value) => User::find($value) ? User::find($value)->name : '',
);
}
public function parent()
{
return $this->belongsTo(Menuitems::class, 'parent_menu')->where('status', 1);
}
public function children()
{
return $this->hasMany(Menuitems::class, 'parent_menu')->orderBy('display_order')->where('status', 1);
}
public function subchildren()
{
return $this->hasMany(Menuitems::class, 'parent_menu')
->where('status', 1)
->orderBy('display_order')
->with('children');
}
}