@ -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'),