36 lines
1.2 KiB
PHP
36 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use Illuminate\Http\Request;
|
|
use \Model\NewsItem;
|
|
|
|
class HomeController extends Controller
|
|
{
|
|
public function show(Request $request)
|
|
{
|
|
$total = 10;
|
|
$page = (int)$request->get('pagina', 1);
|
|
$apiResult = $this->API('nieuws/overzicht?pagina=' . (int)max(1, $page) . '&aantal=' . $total);
|
|
$news = [];
|
|
foreach ($apiResult->news as $newsItem) {
|
|
$news[] = new \Model\NewsItem($newsItem);
|
|
}
|
|
|
|
$populair = [];
|
|
$apiResult = $this->API('nieuws/populair?pagina=' . (int)max(1, $page) . '&aantal=' . $total);
|
|
foreach ($apiResult as $newsItem) {
|
|
$populair[] = new \Model\NewsItem($newsItem);
|
|
}
|
|
|
|
$podcasts = [];
|
|
$apiResult = $this->API('podcast/overzicht?aantal=3');
|
|
$podcast = new \Model\Podcast($apiResult->podcasts[0]);
|
|
foreach ($apiResult->podcasts as $_podcast) {
|
|
$podcasts[] = new \Model\Podcast($_podcast);
|
|
}
|
|
|
|
return view('home', ['populair' => $populair, 'podcasts' => $podcasts, 'podcast' => $podcast, 'title' => 'Home', 'news' => $news, 'searchURL' => 'nieuws/zoeken']);
|
|
}
|
|
}
|