Changes for frontend

This commit is contained in:
2017-07-26 00:07:52 +02:00
parent af370846e6
commit 8b30298ca6
3 changed files with 14 additions and 7 deletions

View File

@@ -1,4 +1,5 @@
syntax: glob syntax: glob
.env .env
api/storage/logs api/storage
*.orig

View File

@@ -63,16 +63,16 @@ QUERY;
/** /**
* Specifiek bericht ophalen * Specifiek bericht ophalen
*/ */
public function item(int $id) { public function item($id) {
$newsItem = app('db')->select(self::$BASE_SQL $newsItem = app('db')->select(self::$BASE_SQL
. ' AND `news`.`id` = :id LIMIT 0, 1', . ' AND `news`.`id` = :id LIMIT 0, 1',
['id' => $id]); ['id' => (int)$id]);
if(count($newsItem) != 1) { if(count($newsItem) != 1) {
return abort(404); return abort(404);
} else { } else {
$pictures = app('db')->select(self::$LOAD_IMAGES, ['newsId' => $id]); $images = app('db')->select(self::$LOAD_IMAGES, ['newsId' => $id]);
return response()->json(new \Model\NewsItem($newsItem[0])); return response()->json(new \Model\NewsItem($newsItem[0], $images));
} }
} }
} }

View File

@@ -29,8 +29,14 @@ class NewsItem extends Model {
parent::ConvertToDateTime($this->published); parent::ConvertToDateTime($this->published);
parent::ConvertToDateTime($this->edited); parent::ConvertToDateTime($this->edited);
$this->source = $data->source ? new \Model\NewsSource($data->source, $data->source_url, $data->showsource) : null; $this->source = null;
$this->keywords = trim($data->keywords) ? explode(' ', $data->keywords) : null; if($data->source)
{
$data->source = is_object($data->source)
? new \Model\NewsSource($data->source->title, $data->source->url, $data->source->url)
: new \Model\NewsSource($data->source, $data->source_url, $data->showsource);
}
$this->keywords = !is_array($data->keywords) && trim($data->keywords) ? explode(' ', $data->keywords) : null;
$this->podcast = $data->podcast ? $data->podcast : null; $this->podcast = $data->podcast ? $data->podcast : null;
$images = ($images != null) ? $images $images = ($images != null) ? $images