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(Newscategories::class, 'parent_category')->where('status', 1); } public function children() { return $this->hasMany(Newscategories::class, 'parent_category')->where('status', 1); } public function news() { return $this->hasMany(News::class, 'newscategories_id', 'category_id')->orderBy('display_order'); } public function entertainmentNews() { return $this->hasMany(News::class, 'newscategories_id', 'category_id')->limit(6)->inRandomOrder()->orderBy('display_order'); } public function technologyNews() { return $this->hasMany(News::class, 'newscategories_id', 'category_id')->limit(6)->inRandomOrder()->orderBy('display_order'); } public function culturalNews() { return $this->hasMany(News::class, 'newscategories_id', 'category_id')->limit(6)->inRandomOrder()->orderBy('display_order'); } public function sportNews() { return $this->hasMany(News::class, 'newscategories_id', 'category_id')->limit(9)->inRandomOrder()->orderBy('display_order'); } public function interviewNews() { return $this->hasMany(News::class, 'newscategories_id', 'category_id')->limit(6)->inRandomOrder()->orderBy('display_order'); } public function politicNews() { return $this->hasMany(News::class, 'newscategories_id', 'category_id')->limit(5)->inRandomOrder()->orderBy('display_order'); } public function branchesNews() { return $this->hasMany(News::class, 'newscategories_id', 'category_id')->limit(6)->inRandomOrder()->orderBy('display_order'); } }