Laatste nieuws balk
This commit is contained in:
@@ -2,11 +2,14 @@
|
||||
|
||||
namespace App\Console;
|
||||
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||
|
||||
class Kernel extends ConsoleKernel
|
||||
{
|
||||
private $API_URL;
|
||||
|
||||
/**
|
||||
* The Artisan commands provided by your application.
|
||||
*
|
||||
@@ -24,6 +27,20 @@ class Kernel extends ConsoleKernel
|
||||
*/
|
||||
protected function schedule(Schedule $schedule)
|
||||
{
|
||||
$this->API_URL = env('API_URL', 'http://api.6fm.nl/');
|
||||
|
||||
// Update latest news (3 items)
|
||||
$schedule->call(function() {
|
||||
$latest_news = json_decode(file_get_contents($this->API_URL . 'nieuws/overzicht?pagina=1&aantal=3'));
|
||||
|
||||
$news = [];
|
||||
foreach($latest_news->news as $item_data)
|
||||
{
|
||||
$news[] = new \Model\NewsItem($item_data);
|
||||
}
|
||||
|
||||
Storage::disk('local')->put('laatste_nieuws.json', json_encode($news));
|
||||
})->everyMinute();
|
||||
// $schedule->command('inspire')
|
||||
// ->hourly();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user