Fix build failures
This commit is contained in:
+53
-34
@@ -2,13 +2,15 @@
|
||||
|
||||
namespace App\Console;
|
||||
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||
|
||||
class Kernel extends ConsoleKernel
|
||||
{
|
||||
private $API_URL;
|
||||
private $API_URL;
|
||||
|
||||
/**
|
||||
* The Artisan commands provided by your application.
|
||||
@@ -19,6 +21,22 @@ class Kernel extends ConsoleKernel
|
||||
//
|
||||
];
|
||||
|
||||
private function getFromApi($url, $file) {
|
||||
$response = Http::connectTimeout(5)
|
||||
->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.
|
||||
*
|
||||
@@ -27,39 +45,40 @@ class Kernel extends ConsoleKernel
|
||||
*/
|
||||
protected function schedule(Schedule $schedule)
|
||||
{
|
||||
$this->API_URL = env('API_URL', 'https://api.nhgooi.nl/');
|
||||
|
||||
// Update latest news (3 items)
|
||||
$schedule->call(function() {
|
||||
Storage::disk('local')->put('laatste_nieuws.json', file_get_contents($this->API_URL . 'nieuws/overzicht?pagina=1&aantal=3'));
|
||||
Storage::disk('local')->put('populair_nieuws.json', file_get_contents($this->API_URL . 'nieuws/populair'));
|
||||
})->everyMinute();
|
||||
|
||||
// Update now / later
|
||||
$schedule->call(function() {
|
||||
Storage::disk('local')->put('nu_straks.json', file_get_contents($this->API_URL . 'programma/schema/nustraks'));
|
||||
Storage::disk('local')->put('zojuist.json', file_get_contents($this->API_URL . 'programma/schema/recent'));
|
||||
})->everyMinute();
|
||||
|
||||
// Update latest podcasts (6 items)
|
||||
$schedule->call(function() {
|
||||
Storage::disk('local')->put('laatste_podcasts.json', file_get_contents($this->API_URL . 'podcast/overzicht?pagina=1&aantal=6'));
|
||||
})->everyMinute();
|
||||
|
||||
// Update calendar items
|
||||
$schedule->call(function() {
|
||||
Storage::disk('local')->put('regioagenda.json', file_get_contents($this->API_URL . 'agenda/overzicht'));
|
||||
})->everyMinute();
|
||||
|
||||
// Update blogs
|
||||
$schedule->call(function() {
|
||||
Storage::disk('local')->put('blogs.json', file_get_contents($this->API_URL . 'blog/overzicht'));
|
||||
})->everyMinute();
|
||||
|
||||
// Update featured images
|
||||
$schedule->call(function() {
|
||||
Storage::disk('local')->put('beelden.json', file_get_contents($this->API_URL . 'beelden/overzicht'));
|
||||
})->everyMinute();
|
||||
$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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user