timeout(15) ->withHeaders([ 'Host' => $this->API_HOST ]) ->get($this->API_URL . $url); if ($response->successful()) { Storage::disk('local')->put( $file, $response->body() ); } } /** * Define the application's command schedule. * * @param \Illuminate\Console\Scheduling\Schedule $schedule * @return void */ protected function schedule(Schedule $schedule) { $this->API_URL = env('API_URL', 'https://api.nhgooi.nl/'); $this->API_HOST = env('API_HOST', $this->API_URL); // Update latest news (3 items) $schedule->call(function () { $this->getFromApi('nieuws/overzicht?pagina=1&aantal=3', 'laatste_nieuws.json'); $this->getFromApi('nieuws/populair', 'populair_nieuws.json'); })->everyMinute(); // Update now / later $schedule->call(function () { $this->getFromApi('programma/schema/nustraks', 'nu_straks.json'); $this->getFromApi('programma/schema/recent', 'zojuist.json'); })->everyMinute(); // Update latest podcasts (6 items) $schedule->call(function () { $this->getFromApi('podcast/overzicht?pagina=1&aantal=6', 'laatste_podcasts.json'); })->everyMinute(); // Update calendar items $schedule->call(function () { $this->getFromApi('agenda/overzicht', 'regioagenda.json'); })->everyMinute(); // Update blogs $schedule->call(function () { $this->getFromApi('blog/overzicht', 'blogs.json'); })->everyMinute(); // Update featured images $schedule->call(function () { $this->getFromApi('beelden/overzicht', 'beelden.json'); })->everyMinute(); } /** * Register the Closure based commands for the application. * * @return void */ protected function commands() { require base_path('routes/console.php'); } }