Turned on Index Search

Turned on the new preliminary search on the index page. Still pretty
raw but wanted to make sure all the plumbing was there.

Next stage is to clean it up a bit and make it sexy
This commit is contained in:
Ro 2023-08-21 12:56:26 -07:00
parent e78c2a04fe
commit f9cb8f3a63
No known key found for this signature in database
GPG key ID: 29B551CDBD4D3B50
3 changed files with 37 additions and 2 deletions

View file

@ -2,6 +2,7 @@
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use App\Models\Location;
@ -13,7 +14,6 @@ class FrontIndexController extends Controller
{
$locations = Location::where("active", true)->get();
$count = count($locations);
$terms = "no|agenda";
$recent = Location::where("active", true)
->limit(5)->orderByDesc('updated_at')->get();
@ -26,6 +26,27 @@ class FrontIndexController extends Controller
]);
}
public function indexSearch(Request $request)
{
$terms = $request->index_search;
$rawSearch = $terms;
$terms = str_replace(",", "", $terms);
$terms = str_replace(" ", "|", $terms);
$results = DB::select("SELECT * FROM searchlocations('$terms')");
$locations = Location::where("active", true)->get();
$count = count($locations);
$recent = Location::where("active", true)
->limit(5)->orderByDesc('updated_at')->get();
return view('front.index', [
'count' => $count,
'recent' => $recent,
'title' => "The Bad Space",
'results' => $results
]);
}
public function about()
{
return view('front.about', [
@ -41,7 +62,7 @@ class FrontIndexController extends Controller
$name = $location->name;
}
return view('front.location', [
'title' => $name,
'title' => str_replace(".", " ", $name),
'location' => $location,
'images' => json_decode($location->images),
'updated' => $location->updated_at->format('Y M d'),

View file

@ -8,8 +8,21 @@
<button aria-label="search-button">
<img class="button-icon" src="assets/images/global/icon-search.svg" />
</button>
@csrf
</form>
</section>
@isset($results)
<section>
<article>
<strong>
Found {{count($results)}} results:
</strong><br>
@foreach($results as $location)
<a role="listitem" href="/location/{{$location->uuid}}">{{$location->name}}</a></a><br />
@endforeach
</article>
</section>
@endisset
<section class="index-meta">
<article>
<strong>{{$count}}</strong>

View file

@ -22,6 +22,7 @@ Route::get("/", [FrontIndexController::class, 'start']);
Route::get("/listings/{pageNum}", [FrontIndexController::class, 'listings']);
Route::get("/about", [FrontIndexController::class, 'about']);
Route::get("/location/{uuid}", [FrontIndexController::class, 'location']);
Route::post("/search", [FrontIndexController::class, 'indexSearch']);
//auth
Route::get("/login", [AuthController::class, 'showLogin']);