fox/app/Livewire/Widgets/Weather.php

29 lines
537 B
PHP

<?php
namespace App\Livewire\Widgets;
use App\Services\WeatherService;
use Livewire\Attributes\On;
use Livewire\Component;
class Weather extends Component
{
public array $w = [];
public function mount(WeatherService $service): void
{
$this->w = $service->fetch();
}
#[On('echo:fox,.stats.weather')]
public function onWeather(array $payload): void
{
$this->w = $payload;
}
public function render()
{
return view('livewire.widgets.weather', ['w' => $this->w]);
}
}