rbibby/laravel-dashboard-news-tile

NewsApi.org tile for Laravel Dashboard

v1.0.0 2020-11-11 21:21 UTC

This package is auto-updated.

Last update: 2024-09-12 06:01:52 UTC


README

Packagist Version GitHub license GitHub Workflow Status

Buy us a tree

Displays latest news on your Laravel Dashboard using newsapi.org

This tile can be used on the Laravel Dashboard.

Installation

You can install the package via composer:

composer require rbibby/laravel-dashboard-news-tile

Configuration

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

The api-key option should contain your API key from https://newsapi.org/. It is recommended this is set in an env variable.

The country-code option sets which country to list news from. For a list of valid country codes, see the newsapi.org.uk documentation

The number-of-articles option determines how many articles to show on the dashboard.

The refresh-interval-in-seconds option determines how many seconds will pass before the dashboard tile is re-rendered.

// config/dashboard.php

return [
    // ...
    'tiles' => [
        'news' => [
            'api-key' => env('NEWS_API_KEY'),
            'country-code' => 'gb',
            'number-of-articles' => 10,
            'refresh-interval-in-seconds' => 60,
        ],
    ],
];

In app\Console\Kernel.php you should schedule the \RBibby\NewsTile\FetchDataFromApiCommand to run. You can let it run every minute if you want. You could also run it less frequently if fast updates on the dashboard aren't that important for this tile.

// app/Console/Kernel.php

protected function schedule(Schedule $schedule)
{
    // ...
    $schedule->command(\RBibby\NewsTile\FetchDataFromApiCommand::class)->everyMinute();
}

Usage

In your dashboard view you use the livewire:news-tile component.

<x-dashboard>
    <livewire:news-tile position="e7:e16" />
</x-dashboard>

Testing

composer test

Changelog

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

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email hello@rbibby.co.uk instead of using the issue tracker.

Credits

Treeware

This package is Treeware. If you use it in production, then we ask that you buy the world a tree to thank us for our work. By contributing to the Treeware forest you’ll be creating employment for local families and restoring wildlife habitats.