@@ -10,24 +10,31 @@ class HomeController extends Controller
|
||||
public function show(Request $request)
|
||||
{
|
||||
$page = (int) $request->get('pagina', 1);
|
||||
$apiResult = $this->API('nieuws/overzicht?pagina=' . (int) max(1, $page) . '&aantal=10');
|
||||
$apiResult = (object) $this->API('nieuws/overzicht?pagina=' . (int) max(1, $page) . '&aantal=10');
|
||||
$news = [];
|
||||
foreach ($apiResult->news as $newsItem) {
|
||||
$news[] = new \Model\NewsItem($newsItem);
|
||||
if ($apiResult && isset($apiResult->news)) {
|
||||
foreach ($apiResult->news as $newsItem) {
|
||||
$news[] = new \Model\NewsItem((object) $newsItem);
|
||||
}
|
||||
}
|
||||
|
||||
$apiResult = $this->API('nieuws/liveblogs');
|
||||
$liveblogs = $apiResult->liveblogs;
|
||||
$apiResult = (object) $this->API('nieuws/liveblogs');
|
||||
$liveblogs = $apiResult && isset($apiResult->liveblogs) ? $apiResult->liveblogs : [];
|
||||
|
||||
$populair = [];
|
||||
$apiResult = $this->API('nieuws/populair?pagina=' . (int) max(1, $page) . '&aantal=5');
|
||||
foreach ($apiResult->news as $newsItem) {
|
||||
$populair[] = new \Model\NewsItem($newsItem);
|
||||
$apiResult = (object) $this->API('nieuws/populair?pagina=' . (int) max(1, $page) . '&aantal=5');
|
||||
if ($apiResult && isset($apiResult->news)) {
|
||||
foreach ($apiResult->news as $newsItem) {
|
||||
$populair[] = new \Model\NewsItem((object) $newsItem);
|
||||
}
|
||||
}
|
||||
|
||||
$apiResult = $this->API('podcast/overzicht?aantal=15');
|
||||
$index = array_rand($apiResult->podcasts);
|
||||
$podcast = new \Model\Podcast($apiResult->podcasts[$index]);
|
||||
$podcast = null;
|
||||
$apiResult = (object) $this->API('podcast/overzicht?aantal=15');
|
||||
if ($apiResult && isset($apiResult->podcasts) && !empty($apiResult->podcasts)) {
|
||||
$index = array_rand($apiResult->podcasts);
|
||||
$podcast = new \Model\Podcast((object) $apiResult->podcasts[$index]);
|
||||
}
|
||||
return view('home', ['populair' => $populair, 'podcast' => $podcast, 'title' => 'Home', 'news' => $news, 'liveblogs' => $liveblogs, 'searchURL' => 'nieuws/zoeken']);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user