Files
einundzwanzig-portal/app/Http/Livewire/Frontend/Header.php
Benjamin Takats d8f66f61f3 split into modules
2022-12-12 16:21:10 +01:00

52 lines
1.3 KiB
PHP

<?php
namespace App\Http\Livewire\Frontend;
use App\Models\City;
use App\Models\Country;
use Illuminate\Support\Facades\Route;
use Livewire\Component;
class Header extends Component
{
public ?Country $country = null;
public $currentRouteName;
public string $c = 'de';
public bool $withGlobe = true;
public function rules()
{
return [
'c' => 'required',
];
}
public function mount()
{
if (!$this->country) {
$this->country = Country::query()
->where('code', $this->c)
->first();
}
$this->currentRouteName = Route::currentRouteName();
$this->c = $this->country->code;
}
public function updatedC($value)
{
return to_route($this->currentRouteName, ['country' => $value]);
}
public function render()
{
return view('livewire.frontend.header', [
'cities' => City::query()
->select(['latitude', 'longitude'])
->get(),
'countries' => Country::query()
->select(['code', 'name'])
->get(),
]);
}
}