baspa/filament-buienradar-widget

Widget to show the Dutch forecast in a Filament widget

dev-main 2024-08-27 06:46 UTC

This package is auto-updated.

Last update: 2024-10-27 08:04:47 UTC


README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

This package provides a Filament widget to show the Dutch forecast from Buienradar. The package is based on the Buienradar PHP package.

Installation

You can install the package via composer:

composer require baspa/filament-buienradar-widget

You can publish the config file with:

 php artisan vendor:publish --tag="buienradar-widget-config"

Optionally, you can publish the views using

php artisan vendor:publish --tag="buienradar-widget-views"

This is the contents of the published config file:

return [
    'station' => MeasuringStation::VOLKEL,
    'show' => [
        'temperature' => true,
        'weather_description' => true,
        'wind_speed' => true,
        'stationname' => true,
        'humidity' => true,
        'last_update' => true,
    ],
];

To check what stations are available, you can check the MeasuringStation enum in the Buienradar package.

Usage

Add the widget to your Filament page via your provider:

use Baspa\FilamentBuienradarWidget\Widgets\FilamentBuienradarWidgetPlugin;

// ...

->plugin(FilamentBuienradarWidgetPlugin::make())

And optionally add the widgets to your page:

use Baspa\FilamentBuienradarWidget\Widgets\ForecastReportWidget;
use Baspa\FilamentBuienradarWidget\Widgets\ForecastLongTermWidget;
use Baspa\FilamentBuienradarWidget\Widgets\ForecastShortTermWidget;
use Baspa\FilamentBuienradarWidget\Widgets\ForecastForStationWidget;

// ...

public function getHeaderWidgetsColumns(): int
{
    return 12;
}

public function getHeaderWidgets(): array
{
    return [
        ForecastForStationWidget::make([
            'width' => 4, // Define the width of the widget
        ]),
        ForecastShortTermWidget::make([
            'width' => 4,
        ]),
        ForecastLongTermWidget::make([
            'width' => 4,
        ]),
        ForecastReportWidget::make([
            'width' => 12,
        ]),
    ];
}

Forecast for station

Forecast for station

Set the station per widget

To set the station per widget, you can pass the station in the widget. This will override the station set in the config.

use Baspa\Buienradar\Enum\MeasuringStation;

// ...

ForecastForStationWidget::make([
    'station' => MeasuringStation::VOLKEL,
])

Forecast report

Forecast report

Forecast short term

Forecast short term

Forecast long term

Forecast long term

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.