Zoekfunctie
This commit is contained in:
@@ -106,24 +106,19 @@ QUERY;
|
|||||||
|
|
||||||
public function findnews(Request $request, $query) {
|
public function findnews(Request $request, $query) {
|
||||||
$page = (int)$request->get('pagina', 1);
|
$page = (int)$request->get('pagina', 1);
|
||||||
|
$count = (int)$request->get('aantal', 15);
|
||||||
if($page <= 0) {
|
if($page <= 0) {
|
||||||
return abort(400);
|
return abort(400);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$start = ($page - 1) * $count;
|
||||||
$query = strip_tags(urldecode($query));
|
$query = strip_tags(urldecode($query));
|
||||||
$searchRange = [
|
$newsItems = app('db')->select($s=self::$BASE_SQL
|
||||||
(new \DateTimeImmutable())->setDate(date('Y') + 1 - $page, 1, 1),
|
. ' AND MATCH(`content`.`title`, `content`.`content`) AGAINST(:query IN NATURAL LANGUAGE MODE)'
|
||||||
(new \DateTimeImmutable())->setDate(date('Y') + 2 - $page, 1, 1)];
|
|
||||||
|
|
||||||
$newsItems = app('db')->select(self::$BASE_SQL
|
|
||||||
. ' AND `news`.`creationdt` >= :startRange AND `news`.`creationdt` <= :endRange'
|
|
||||||
. ' AND MATCH(`content`.`title`, `content`.`content`) AGAINST(:query IN BOOLEAN MODE)'
|
|
||||||
. ' ORDER BY COALESCE(`news`.`pubupdatedt`, `news`.`creationdt`) DESC'
|
. ' ORDER BY COALESCE(`news`.`pubupdatedt`, `news`.`creationdt`) DESC'
|
||||||
. ' LIMIT 0, 20', [
|
. ' LIMIT ' . $start . ', ' . $count, [
|
||||||
'category' => self::$NEWS_CATEGORY,
|
'category' => self::$NEWS_CATEGORY,
|
||||||
'secondarycategory' => self::$EXTERNAL_NEWS_CATEGORY,
|
'secondarycategory' => self::$EXTERNAL_NEWS_CATEGORY,
|
||||||
'startRange' => $searchRange[0]->format('Y-m-d'),
|
|
||||||
'endRange' => $searchRange[1]->format('Y-m-d'),
|
|
||||||
'query' => $query
|
'query' => $query
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|||||||
@@ -86,22 +86,17 @@ QUERY;
|
|||||||
|
|
||||||
public function findpodcast(Request $request, $query) {
|
public function findpodcast(Request $request, $query) {
|
||||||
$page = (int)$request->get('pagina', 1);
|
$page = (int)$request->get('pagina', 1);
|
||||||
|
$count = (int)$request->get('aantal', 15);
|
||||||
if($page <= 0) {
|
if($page <= 0) {
|
||||||
return abort(400);
|
return abort(400);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$start = ($page - 1) * $count;
|
||||||
$query = strip_tags(urldecode($query));
|
$query = strip_tags(urldecode($query));
|
||||||
$searchRange = [
|
|
||||||
(new \DateTimeImmutable())->setDate(date('Y') + 1 - $page, 1, 1),
|
|
||||||
(new \DateTimeImmutable())->setDate(date('Y') + 2 - $page, 1, 1)];
|
|
||||||
|
|
||||||
$podcasts = app('db')->select(self::$BASE_SQL
|
$podcasts = app('db')->select(self::$BASE_SQL
|
||||||
. ' AND `podcast_meta`.`creationdt` >= :startRange AND `podcast_meta`.`creationdt` <= :endRange'
|
. ' AND MATCH(`podcast_meta`.`title`, `podcast_meta`.`content`) AGAINST(:query IN NATURAL LANGUAGE MODE)'
|
||||||
. ' AND MATCH(`podcast_meta`.`title`, `podcast_meta`.`content`) AGAINST(:query IN BOOLEAN MODE)'
|
|
||||||
. ' ORDER BY `creationdt` DESC'
|
. ' ORDER BY `creationdt` DESC'
|
||||||
. ' LIMIT 0, 20', [
|
. ' LIMIT ' . $start . ', ' . $count, [
|
||||||
'startRange' => $searchRange[0]->format('Y-m-d'),
|
|
||||||
'endRange' => $searchRange[1]->format('Y-m-d'),
|
|
||||||
'query' => $query
|
'query' => $query
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user