Files
riksdagen-app/app/Livewire/Person/Search.php
2025-12-20 17:44:35 +01:00

37 lines
793 B
PHP

<?php
namespace App\Livewire\Person;
use Livewire\Component;
use App\Services\RiksdagenService;
use App\Enums\Parties;
class Search extends Component
{
public $firstName = '';
public $lastName = '';
public $party = '';
public $results = [];
public $parties = [];
public function mount()
{
$this->parties = collect(Parties::cases())->sortBy(fn($party) => $party->label())->toArray();
}
public function search()
{
$service = app(RiksdagenService::class);
$this->results = $service->searchPerson(
firstName: $this->firstName,
lastName: $this->lastName,
party: $this->party
)->original;
}
public function render()
{
return view('livewire.person.search');
}
}