37 lines
851 B
PHP
37 lines
851 B
PHP
<?php
|
|
|
|
namespace App\Livewire\Patient;
|
|
|
|
use App\Models\News as NewsModel;
|
|
use Livewire\Component;
|
|
use Livewire\WithPagination;
|
|
use Masmerise\Toaster\Toaster;
|
|
use Illuminate\Support\Facades\Storage;
|
|
|
|
class News extends Component
|
|
{
|
|
use WithPagination;
|
|
|
|
public $search = '';
|
|
|
|
protected $queryString = [
|
|
'search' => ['except' => ''],
|
|
];
|
|
|
|
public function updatedSearch()
|
|
{
|
|
$this->resetPage();
|
|
}
|
|
|
|
public function render()
|
|
{
|
|
return view('livewire.patient.news.news', [
|
|
'news' => NewsModel::with('category')
|
|
->where('is_published', true) // Pastikan hanya berita yang terbit
|
|
->where('title', 'like', '%' . $this->search . '%')
|
|
->latest()
|
|
->paginate(12) // Gunakan kelipatan 3 atau 4 untuk grid yang pas
|
|
]);
|
|
}
|
|
}
|