$results = Stock::whereHas('receiptNotes',function ($query) { $query->where('status', 'approved'); })->where(function ($query) use ($q) { $query->where('name','like',"%$q%")->orWhere('code','like',"%$q%"); })->limit(10)->get();
#salipro: bug laravel, khong hoat dong neu nhu the nay
//->where('name','like',"%$q%")
//->orWhere('code','like',"%$q%")