I'm trying to implement filtering as defined here.
I have two databases and with a different model on each. I can query and eager load these fine without any filtering. I have implemented a manual/hacky filtering via the detailed above filter class:
BidFilter.php
<?php
protected function sn($sn)
{
$bid = DB::connection('sqlsrv')->table('Bids')->select('*')->where('crm_ref', '=', $sn)->get();
$crm = DB::connection('sqlsrv_crm')->table('OpportunityBase')->select('*')->where('new_SalesNumber', '=', $sn)->get();
return $bid->merge($crm);
}
By looking at the debugbar queries, this looks like it works. However, it is also loading the normal eager loaded/main set of results that show up when viewing unfiltered:
Debugbar
How can I override what is being fed into the view to pass only my filtered results?
BidController
<?php
public function index(BidFilter $filters)
{
$bids = $this->getBids($filters);
return view('public.bids.index', compact('bids'));
}
protected function getBids(BidFilter $filters)
{
$bids = Bid::with('crm')->filter($filters);
return $bids->paginate(10);
}