NewsApi.org tile for Laravel Dashboard
rbibby/laravel-dashboard-news-tile is a Laravel package for newsapi.org tile for laravel dashboard.
It currently has 1 GitHub stars and 3 downloads on Packagist (latest version v1.0.0).
Install it with composer require rbibby/laravel-dashboard-news-tile.
Discover more Laravel packages by rbibby
or browse all Laravel packages to compare alternatives.
Last updated
Displays latest news on your Laravel Dashboard using newsapi.org
This tile can be used on the Laravel Dashboard.
You can install the package via composer:
composer require rbibby/laravel-dashboard-news-tile
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();
}
In your dashboard view you use the livewire:news-tile component.
<x-dashboard>
<livewire:news-tile position="e7:e16" />
</x-dashboard>
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
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.