ldc-groupe/app/View/Components/Front/News/NewsNextEventComponent.php

37 lines
873 B
PHP

<?php
namespace App\View\Components\Front\News;
use App\Models\News;
use Closure;
use Illuminate\Contracts\View\View;
use Illuminate\View\Component;
class NewsNextEventComponent extends Component
{
public $nextEvents;
/**
* Create a new component instance.
*/
public function __construct()
{
$this->nextEvents = News::with('categories')
->whereHas('categories', function ($query) {
$query->where('slug', 'event'); #FIXME: ici c'est en dure et ça sera à fixer plus tard
})
->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
]);
}
}