filter(fn($category) => $category->getTranslation('slug', 'fr') === "actualites") ->first(); $eventTag = NewsTag::getTagsByCategoryInCurrentLocale($newsCategory->slug) ->filter(fn($tag) => $tag->getTranslation('slug', 'fr') === "evenement") ->first(); $eventTagId = $eventTag ? $eventTag->id : null; $this->nextEvents = News::getPublishedNewsByCategoryInCurrentLocale($newsCategory->slug) ->filter(function ($news) use ($eventTagId) { return $news->tags->contains( fn ($tag) => $eventTagId === $tag->id ); }) ->sortByDesc('published_at') ->take(3); } /** * 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 ]); } }