Files
riksdagen-app/app/Livewire/Person/Search.php

42 lines
800 B
PHP

<?php
namespace App\Livewire\Person;
use App\Enums\Parties;
use App\Services\RiksdagenService;
use Livewire\Component;
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');
}
}