I'm trying to merge the results of two queries in Laravel Nova. I've read the documentation but haven't found a solution yet. Basically, I want to merge two query results and display them in a resource table.
I tried overriding the indexQuery
method but failed. refer to
public static function indexQuery(NovaRequest $request, $query){ $query_1 = Model::where('some condition')->get(); $query_2 = Model2::where('some condition')->get(); //merge both queries result $result = $query_1->merge($query_2); return $result }
You can try the following, although the way to do it in nova is weird:
I prefer
dd($result);
before passing it back to the field to ensure the field is built based on the new collection. You can view the results in the Network tab.