kayschima/laravel-dashboard-footballdata-standings-tile

A tile for Laravel Dashboard that displays football standings of different leagues

1.0.1 2020-09-09 18:49 UTC

This package is auto-updated.

Last update: 2024-06-10 04:01:51 UTC


README

Latest Version on PackagistTotal Downloads

This tile can used on the Laravel Dashboard to display standings from www.football-data.org.

License

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

Installation

You can install the tile via composer:

composer require kayschima/laravel-dashboard-footballdata-standings-tile

In the dashboard config file, you must add this configuration in the tiles key.

Sign up at https://www.football-data.org/ to obtain FOOTBALLDATA_API_KEY.

Set FOOTBALL_LEAGUE to a league shortcut of the football-data.org service (e.g. BL1 or PL).

// in config/dashboard.php

return [
    // ...
    'tiles' => [
        'footballstandings' => [
            'footballdata_api_key' => env('FOOTBALLDATA_API_KEY'),
            'football_league' => env('FOOTBALL_LEAGUE'),
        ]
    ],
];

In app\Console\Kernel.php you should schedule

  • the Kayschima\FootballStandingsTile\Commands\FetchFootballStandingsDataCommand and
  • the Kayschima\FootballStandingsTile\Commands\FetchFootballLiveResultsDataCommand

to run every minute.

// in app/console/Kernel.php

use Kayschima\FootballStandingsTile\Commands\FetchFootballStandingsDataCommand;
use Kayschima\FootballStandingsTile\Commands\FetchFootballLiveResultsDataCommand;

protected function schedule(Schedule $schedule)
{
    // ...
    $schedule->command(FetchFootballStandingsDataCommand::class)->everyMinute();
    $schedule->command(FetchFootballLiveResultsDataCommand::class)->everyMinute();
}      

Views

In your dashboard views you use

  • the livewire:football-standings-tile component and/or
  • the livewire:football-live-results-tile component.

An optional $highlight-attribute to the livewire:football-standings-tile triggers a simple highlighting of e.g. the local or favourite team what is expected to be a common use case for the tile.

For simplicity, this commit uses the id of the team, specific to every competition -- "4" in this case for BVB @ 1. Bundesliga.

<x-dashboard>
    <livewire:football-standings-tile position="a1" highlight="4" />
    <livewire:football-live-results-tile position="b1"/>
</x-dashboard>

Customizing the views

php artisan vendor:publish --provider="Kayschima\FootballStandingsTile\FootballStandingsTileServiceProvider" --tag="dashboard-football-standings-tile-views"