forked from projects/thebadspace
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:
parent
e78c2a04fe
commit
f9cb8f3a63
3 changed files with 37 additions and 2 deletions
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use App\Models\Location;
|
use App\Models\Location;
|
||||||
|
|
||||||
|
@ -13,7 +14,6 @@ class FrontIndexController extends Controller
|
||||||
{
|
{
|
||||||
$locations = Location::where("active", true)->get();
|
$locations = Location::where("active", true)->get();
|
||||||
$count = count($locations);
|
$count = count($locations);
|
||||||
$terms = "no|agenda";
|
|
||||||
$recent = Location::where("active", true)
|
$recent = Location::where("active", true)
|
||||||
->limit(5)->orderByDesc('updated_at')->get();
|
->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()
|
public function about()
|
||||||
{
|
{
|
||||||
return view('front.about', [
|
return view('front.about', [
|
||||||
|
@ -41,7 +62,7 @@ class FrontIndexController extends Controller
|
||||||
$name = $location->name;
|
$name = $location->name;
|
||||||
}
|
}
|
||||||
return view('front.location', [
|
return view('front.location', [
|
||||||
'title' => $name,
|
'title' => str_replace(".", " ", $name),
|
||||||
'location' => $location,
|
'location' => $location,
|
||||||
'images' => json_decode($location->images),
|
'images' => json_decode($location->images),
|
||||||
'updated' => $location->updated_at->format('Y M d'),
|
'updated' => $location->updated_at->format('Y M d'),
|
||||||
|
|
|
@ -8,8 +8,21 @@
|
||||||
<button aria-label="search-button">
|
<button aria-label="search-button">
|
||||||
<img class="button-icon" src="assets/images/global/icon-search.svg" />
|
<img class="button-icon" src="assets/images/global/icon-search.svg" />
|
||||||
</button>
|
</button>
|
||||||
|
@csrf
|
||||||
</form>
|
</form>
|
||||||
</section>
|
</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">
|
<section class="index-meta">
|
||||||
<article>
|
<article>
|
||||||
<strong>{{$count}}</strong>
|
<strong>{{$count}}</strong>
|
||||||
|
|
|
@ -22,6 +22,7 @@ Route::get("/", [FrontIndexController::class, 'start']);
|
||||||
Route::get("/listings/{pageNum}", [FrontIndexController::class, 'listings']);
|
Route::get("/listings/{pageNum}", [FrontIndexController::class, 'listings']);
|
||||||
Route::get("/about", [FrontIndexController::class, 'about']);
|
Route::get("/about", [FrontIndexController::class, 'about']);
|
||||||
Route::get("/location/{uuid}", [FrontIndexController::class, 'location']);
|
Route::get("/location/{uuid}", [FrontIndexController::class, 'location']);
|
||||||
|
Route::post("/search", [FrontIndexController::class, 'indexSearch']);
|
||||||
|
|
||||||
//auth
|
//auth
|
||||||
Route::get("/login", [AuthController::class, 'showLogin']);
|
Route::get("/login", [AuthController::class, 'showLogin']);
|
||||||
|
|
Loading…
Reference in a new issue