38 lines
880 B
PHP
38 lines
880 B
PHP
<?php
|
|
|
|
namespace App\View\Components\Front\News;
|
|
|
|
use App\Enums\News\NewsCategoryEnum;
|
|
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('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
|
|
]);
|
|
}
|
|
}
|