24 lines
590 B
PHP
24 lines
590 B
PHP
<?php
|
|
|
|
namespace App\Livewire\Guest;
|
|
|
|
use App\Models\News;
|
|
use Livewire\Component;
|
|
use Livewire\WithPagination;
|
|
|
|
class NewsIndex extends Component
|
|
{
|
|
use WithPagination;
|
|
|
|
public function render()
|
|
{
|
|
return view('livewire.guest.news-index', [
|
|
// Menggunakan with('category') untuk mencegah N+1 query dan error JSON
|
|
'news' => News::where('is_published', true)
|
|
->with('category')
|
|
->latest()
|
|
->paginate(9)
|
|
])->layout('components.guest-layout', ['title' => 'Berita & Edukasi Kesehatan']);
|
|
}
|
|
}
|