Skip to content

A tile bringing newsapi.org support to spatie/laravel-dashboard.

License

Notifications You must be signed in to change notification settings

rbibby/laravel-dashboard-news-tile

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NewsApi.org Laravel Dashboard Tile

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 [email protected] 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.

About

A tile bringing newsapi.org support to spatie/laravel-dashboard.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published