Files
huginn/app/Livewire/Sites/Index.php
T
m105 f15eb5aec1 Add first pass of the web interface: Sites index + detail, via Livewire
Home page is now a Livewire-powered, searchable/paginated Site list
(search by domain) instead of the stock Laravel welcome page. Clicking
a site goes to a plain controller-rendered detail page listing its
pages. Shared layout at resources/views/components/layouts/app.blade.php.
2026-07-22 21:16:17 +03:00

39 lines
853 B
PHP

<?php
namespace App\Livewire\Sites;
use App\Models\Site;
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
{
$sites = Site::query()
->withCount('pages')
->when(
$this->search !== '',
fn ($query) => $query->where('domain', 'like', '%'.$this->search.'%')
)
->orderBy('domain')
->paginate(25);
return view('livewire.sites.index', ['sites' => $sites]);
}
}