Skip to content

Commit

Permalink
Filtrera bort sökord som är för korta och de utan datum
Browse files Browse the repository at this point in the history
  • Loading branch information
bonny committed Apr 23, 2024
1 parent cc79dbb commit 55066dd
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions app/Http/Controllers/SearchController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Creitive\Breadcrumbs\Breadcrumbs;
use Illuminate\Http\Request;
use Illuminate\Support\Collection;

/**
* Söksidan
Expand All @@ -30,11 +31,20 @@ public function adsenseSearch(Request $request) {
* @return array
*/
public static function getSearches($only_with_hits = false) {
/** @var array */
$searches = \Setting::get('searches3', []);
$searches = Collection::make( \Setting::get('searches3', []) );

// Ta bort för korta sökningar.
$searches = $searches->reject(function ($vals, $key) {
return strlen($key) < 3;
});

// Ta bort sökningar utan datum (gamla setting, försvinner automatiskt).
$searches = $searches->reject(function ($search) {
return !isset($search['last']);
});

if ($only_with_hits) {
$searches = array_filter($searches, function ($search) {
$searches = $searches->filter(function ($search) {
return $search['hits'] > 0;
});
}
Expand Down

0 comments on commit 55066dd

Please sign in to comment.