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