diff --git a/api/app/Http/Controllers/NewsController.php b/api/app/Http/Controllers/NewsController.php index ed1c9b8..b006f55 100644 --- a/api/app/Http/Controllers/NewsController.php +++ b/api/app/Http/Controllers/NewsController.php @@ -13,7 +13,8 @@ SELECT `news`.`id`, `content`.`title`, `content`.`content`, `news`.`podcast` AS `news`.`creationdt` AS `published`, `content`.`creator`, `news`.`pubupdatedt` AS `edited`, `news`.`startdt` AS `starts`, `news`.`enddt` AS `ends`, `content`.`showsource` AS `showsource`, `sources`.`title` AS `source`, `sources`.`url` AS `source_url`, - `themes`.`title` AS `theme`, `themes`.`thumbnail` AS `theme_thumbnail`, `regions`.`title` AS `region`, `regions`.`slug` as `region_slug` + `themes`.`title` AS `theme`, `themes`.`thumbnail` AS `theme_thumbnail`, `themes`.`slug` AS `theme_slug`, + `regions`.`title` AS `region`, `regions`.`slug` as `region_slug` FROM `news` LEFT JOIN `news_target_content` AS `content` ON `content`.`news` = `news`.`id` LEFT JOIN `news_regions` AS `regions` ON `regions`.`id` = `news`.`region` @@ -76,6 +77,10 @@ QUERY; return $this->newslist($request, ['`regions`.`slug`' => $region]); } + public function themelist(Request $request, $theme) { + return $this->newslist($request, ['`themes`.`slug`' => $theme]); + } + /** * Agendaberichten ophalen */ diff --git a/api/routes/web.php b/api/routes/web.php index 1863204..fe7aa4f 100644 --- a/api/routes/web.php +++ b/api/routes/web.php @@ -17,6 +17,7 @@ $app->get('/', function () use ($app) { $app->get('nieuws/overzicht', 'NewsController@newslist' ); $app->get('nieuws/regio/{region:[a-z0-9]+}', 'NewsController@regionlist' ); +$app->get('nieuws/thema/{theme:[a-z0-9]+}', 'NewsController@themelist' ); $app->get('nieuws/populair', 'NewsController@popularNews' ); $app->get('nieuws/bericht/{id:\d+}', 'NewsController@newsitem' ); $app->get('nieuws/regionieuws', 'PodcastController@latestNews' ); diff --git a/common/classes/NewsItem.php b/common/classes/NewsItem.php index aa20c30..1ea5c18 100644 --- a/common/classes/NewsItem.php +++ b/common/classes/NewsItem.php @@ -65,6 +65,13 @@ class NewsItem extends Model { $this->region = new \Model\NewsRegion($data->region, $data->region_slug); } + if(is_object($data->theme)) { + $this->theme = new \Model\NewsRegion($data->theme->title, $data->theme->slug); + } else { + $this->theme = new \Model\NewsRegion($data->theme, $data->theme_slug); + } + + $images = ($images != null) ? $images : (isset($data->images) ? $data->images : null); if($images) {