nextEvents = News::with('categories') ->whereHas('categories', function ($query) { $query->where('category', NewsCategoryEnum::event->value); }) ->latest() ->take(3) ->get(); } /** * Get the view / contents that represent the component. */ public function render(): View|Closure|string { return view('components.front.news.news-next-event-component', [ 'nextEvents' => $this->nextEvents ]); } }