Now playing en mega menu
This commit is contained in:
@@ -17,7 +17,7 @@ class Controller extends BaseController
|
||||
|
||||
protected $API_URL;
|
||||
|
||||
private function getDataFromFileAndConvert($file, $path, $class)
|
||||
private function getDataFromFileAndConvert($file, $path, $class, $maxItems = 0)
|
||||
{
|
||||
$data = json_decode(Storage::disk('local')->get($file));
|
||||
foreach($path as $subobject) { $data = $data->$subobject; }
|
||||
@@ -25,6 +25,7 @@ class Controller extends BaseController
|
||||
foreach($data as $item_data)
|
||||
{
|
||||
$items[] = new $class($item_data);
|
||||
if($maxItems && count($items) == $maxItems) { break; }
|
||||
}
|
||||
|
||||
return $items;
|
||||
@@ -33,6 +34,7 @@ class Controller extends BaseController
|
||||
public function __construct()
|
||||
{
|
||||
View::share('apiUrl', $this->API_URL = env('API_URL', 'http://api.6fm.nl/'));
|
||||
//View::share('onAir', file_get_contents(url('onair')));
|
||||
View::composer('widgets.laatstenieuws', function($view) {
|
||||
$view->with('data', $this->getDataFromFileAndConvert('laatste_nieuws.json', ['news'], '\Model\NewsItem'));
|
||||
});
|
||||
@@ -55,6 +57,11 @@ class Controller extends BaseController
|
||||
View::composer('widgets.laatstepodcasts', function($view) {
|
||||
$view->with('data', $this->getDataFromFileAndConvert('laatste_podcasts.json', ['podcasts'], '\Model\Podcast'));
|
||||
});
|
||||
View::composer('widgets.menu', function($view) {
|
||||
$view->with('news', $this->getDataFromFileAndConvert('laatste_nieuws.json', ['news'], '\Model\NewsItem'))
|
||||
->with('popular', $this->getDataFromFileAndConvert('populair_nieuws.json', [], '\Model\NewsItem', 3))
|
||||
->with('podcasts', $this->getDataFromFileAndConvert('laatste_podcasts.json', ['podcasts'], '\Model\Podcast'));
|
||||
});
|
||||
}
|
||||
|
||||
protected function registerView(Request $request, $type, $id)
|
||||
|
||||
@@ -29,7 +29,7 @@ class RadioController extends Controller
|
||||
|
||||
public function onair()
|
||||
{
|
||||
return $this->API('programma/schema/onair')->current->name;
|
||||
return response()->json($this->API('programma/schema/onair?nonstop=1'));
|
||||
}
|
||||
|
||||
public function program($id)
|
||||
|
||||
Reference in New Issue
Block a user