Initial commit
This commit is contained in:
29
app/Http/Controllers/SearchController.php
Normal file
29
app/Http/Controllers/SearchController.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class SearchController extends Controller
|
||||
{
|
||||
public function show(Request $request)
|
||||
{
|
||||
$authId = Auth::guard('web')->id();
|
||||
$key = 'main_search_bar_results_' . $authId;
|
||||
$data = cache()->get($key, ['results' => [], 'searchTerm' => null, 'total' => 0,]);
|
||||
$resultRefs = $data['results'];
|
||||
$searchTerm = $data['searchTerm'];
|
||||
$total = $data['total'];
|
||||
|
||||
|
||||
// empty cache when retrieved
|
||||
// cache()->forget($key);
|
||||
|
||||
return view('search.show', [
|
||||
'resultRefs' => $resultRefs,
|
||||
'searchTerm' => $searchTerm,
|
||||
'total' => $total,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user