New to Inertia and having some trouble figuring this out:
I have a search bar on a Vue page and want to return a set of filtered results for the user to select as a dropdown from the search bar. I'm passing a query parameter from the search bar to the Laravel Controller and performing a where clause with the user query:
public function showFilteredResponse(Request $request)
{
$query = $request->query('query'); //Query passed from Vue
$filteredResults = DB::table('documents')
->where('title', 'like', '%' . $query . '%')->get();
$filteredResults //this contains the data I want the front-end to have access to.
//how can this data be passed to Vue without a full page re-render?
}
How can the $filteredResults data be returned to the user without re-render of the whole page? To render an initial page with data I have the following:
return Jetstream::inertia()->render($request, '/home')->with('documents', $documents);
But if I want to add new data to a page without re-render how can this be done?
If I use inertia()->render()->with(), then sure enough I can access the $filteredResults on the Vue page but I lose the props from the initial page load unless I duplicate queries which doesn't seem like the right way to go.