Return an HTML search screen from /search for browser visits and point the bottom nav Search tab at it instead of the dashboard. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -9,19 +9,22 @@ use App\Models\HostingAccountMember;
|
||||
use App\Models\HostingProduct;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class SearchController extends Controller
|
||||
{
|
||||
public function __invoke(Request $request): JsonResponse
|
||||
public function __invoke(Request $request): JsonResponse|View
|
||||
{
|
||||
$q = trim((string) $request->query('q', ''));
|
||||
$results = mb_strlen($q) >= 2 ? $this->resultsForUser($request->user(), $q) : [];
|
||||
|
||||
if (mb_strlen($q) < 2) {
|
||||
return response()->json(['results' => []]);
|
||||
if ($request->expectsJson() || $request->ajax() || $request->wantsJson()) {
|
||||
return response()->json(['results' => $results]);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'results' => $this->resultsForUser($request->user(), $q),
|
||||
return view('search', [
|
||||
'query' => $q,
|
||||
'results' => $results,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user