31 lines
1019 B
PHP
31 lines
1019 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use Illuminate\Http\Request;
|
|
use \Model\NewsItem;
|
|
|
|
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');
|
|
$news = [];
|
|
foreach ($apiResult->news as $newsItem) {
|
|
$news[] = new \Model\NewsItem($newsItem);
|
|
}
|
|
|
|
$populair = [];
|
|
$apiResult = $this->API('nieuws/populair?pagina=' . (int)max(1, $page) . '&aantal=5');
|
|
foreach ($apiResult->news as $newsItem) {
|
|
$populair[] = new \Model\NewsItem($newsItem);
|
|
}
|
|
|
|
$apiResult = $this->API('podcast/overzicht?aantal=15');
|
|
$index = array_rand($apiResult->podcasts);
|
|
$podcast = new \Model\Podcast($apiResult->podcasts[$index]);
|
|
return view('home', ['populair' => $populair, 'podcast' => $podcast, 'title' => 'Home', 'news' => $news, 'searchURL' => 'nieuws/zoeken']);
|
|
}
|
|
}
|