30 lines
766 B
PHP
30 lines
766 B
PHP
<?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,
|
|
]);
|
|
}
|
|
}
|