2026-07-22 21:16:17 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Livewire\Sites;
|
|
|
|
|
|
|
|
|
|
use App\Models\Site;
|
2026-07-25 15:22:42 +03:00
|
|
|
use App\Support\GuestPreview;
|
2026-07-22 21:16:17 +03:00
|
|
|
use Illuminate\Contracts\View\View;
|
|
|
|
|
use Livewire\Attributes\Layout;
|
|
|
|
|
use Livewire\Attributes\Url;
|
|
|
|
|
use Livewire\Component;
|
|
|
|
|
use Livewire\WithPagination;
|
|
|
|
|
|
|
|
|
|
#[Layout('components.layouts.app')]
|
|
|
|
|
class Index extends Component
|
|
|
|
|
{
|
|
|
|
|
use WithPagination;
|
|
|
|
|
|
|
|
|
|
#[Url(as: 'q', history: true)]
|
|
|
|
|
public string $search = '';
|
|
|
|
|
|
|
|
|
|
public function updatingSearch(): void
|
|
|
|
|
{
|
|
|
|
|
$this->resetPage();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function render(): View
|
|
|
|
|
{
|
2026-07-25 15:22:42 +03:00
|
|
|
$sites = GuestPreview::paginate(
|
|
|
|
|
Site::query()
|
|
|
|
|
->withCount('pages')
|
|
|
|
|
->when(
|
|
|
|
|
$this->search !== '',
|
|
|
|
|
fn ($query) => $query->where('domain', 'like', '%'.$this->search.'%')
|
|
|
|
|
)
|
|
|
|
|
->orderBy('domain')
|
|
|
|
|
);
|
2026-07-22 21:16:17 +03:00
|
|
|
|
|
|
|
|
return view('livewire.sites.index', ['sites' => $sites]);
|
|
|
|
|
}
|
|
|
|
|
}
|