1
0
mirror of https://koodu.h-i.works/projects/thebadspace synced 2025-06-25 16:04:37 -05:00

Updated search and listing links, added new icons

Search methodolgy has been tweaked and the correspending result links
have been updated, as well as links in the Listing page to display both
silence and suspend counts and the overall heat rating.

Also plugged in new silence and suspend icons provideb by
https://rage.love/@puf. Big thanks for that, man.
This commit is contained in:
ro
2024-01-23 12:04:52 -06:00
parent 0a64de2378
commit 175ea25d7b
7 changed files with 92 additions and 42 deletions

View File

@ -11,24 +11,24 @@ class FrontIndexController extends Controller
{
private $limit = 15;
public function start()
private function getRecent()
{
$sources = Source::where("active", true)->get();
$locations = Location::where("active", true)->orderByDesc('updated_at')->get();
$list = [];
foreach ($locations as $location) {
if (($location->block_count + $location->silence_count) > 2) {
if (($location->block_count + $location->silence_count) >= 2) {
array_push($list, $location);
}
}
return $list;
}
$recentList = Location::where("active", true)
->where('block_count', '>', 2)
->limit(10)->orderByDesc('updated_at')->get();
public function start()
{
$list = $this->getRecent();
return view('front.index', [
'count' => count($list),
'sources' => count($sources),
'sources' => count(Source::where("active", true)->get()),
'recent' => $list,
'title' => "The Bad Space"
]);
@ -36,6 +36,7 @@ class FrontIndexController extends Controller
public function indexSearch(Request $request)
{
// this grabs the search results from the db
$terms = $request->index_search;
$rawSearch = $terms;
$terms = str_replace(",", "", $terms);
@ -48,18 +49,17 @@ class FrontIndexController extends Controller
}
}
$locations = Location::where("active", true)->get();
$count = count($locations);
$recent = Location::where("active", true)
->where('block_count', '>', 2)
->where('silence_count', '>', 2)
->limit(10)->orderByDesc('updated_at')->get();
//this gets recent updates to display under search results
$list = $this->getRecent();
return view('front.index', [
'count' => $count,
'recent' => $recent,
'title' => "The Bad Space",
'results' => $results
'count' => count($list),
'sources' => count(Source::where("active", true)->get()),
'recent' => $list,
'results' => $results,
'recent' => $list,
'terms' => $terms,
'title' => "Search Results",
]);
}
@ -92,12 +92,40 @@ class FrontIndexController extends Controller
public function listings(int $pageNum = 1)
{
$range = $pageNum * $this->limit - $this->limit;
$active = Location::where("active", true)->where('block_count', '>', 2)->get();
$locations = Location::where("active", true)->where('block_count', '>', 2)
->limit($this->limit)->offset($range)->orderByDesc('id')->get();
$locations = Location::where("active", true)->get();
$active = [];
foreach ($locations as $location) {
if (($location->block_count + $location->silence_count) >= 2) {
array_push($active, $location);
}
}
$pages = [];
if (count($active) != 0) {
if (count($active) < $this->limit) {
$this->limit = count($active) - 1;
}
$range = $pageNum * $this->limit - $this->limit;
if ($range != 0) {
$range = $range + 1;
}
for ($i = 0; $i <= $this->limit; ++$i) {
if (isset($active[$i + $range])) {
array_push($pages, $active[$i + $range]);
} else {
// chill out
}
}
}
$pageCount = ceil(count($active) / $this->limit);
if ($range != 0) {
$range = $range + 1;
}
$next = $pageNum + 1;
if ($next > $pageCount) {
$next = 1;
@ -111,11 +139,12 @@ class FrontIndexController extends Controller
return view('front.listing', [
'title' => "Listings",
'sources' => count(Source::where("active", true)->get()),
"totalPages" => $pageCount,
"prev" => $prev,
"next" => $next,
'pageNum' => $pageNum,
'locations' => $locations
'locations' => $pages
]);
}
}