Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace App\Filament\Pages;
- use App\Models\PingResult;
- use App\Filament\Widgets\LatencyChartWidgetForUrl;
- use Filament\Pages\Page;
- class Latency extends Page
- {
- protected static ?string $navigationIcon = 'heroicon-o-chart-bar';
- protected static string $view = 'filament.pages.ping-results-page';
- public function getData()
- {
- // Retrieve distinct URLs
- $urls = PingResult::distinct()->pluck('url');
- \Log::info("Retrieved URLs: ", $urls->toArray());
- return [
- 'urls' => $urls,
- 'filters' => $this->getFilters(),
- ];
- }
- protected function getFilters(): array
- {
- return [
- '24h' => 'Last 24h',
- 'week' => 'Last week',
- 'month' => 'Last month',
- ];
- }
- protected function getHeaderWidgets(): array
- {
- $urls = $this->getData()['urls'];
- \Log::info("Creating widgets for URLs: ", $urls->toArray());
- $widgets = [];
- foreach ($urls as $url) {
- $widget = LatencyChartWidgetForUrl::make(); // Create widget instance
- $widget->url = $url; // Directly set URL property
- \Log::info("Assigning URL to widget: " . $url . " - Widget URL: " . $widget->url);
- $widgets[] = $widget;
- }
- return $widgets;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement