clat23
1 year ago

Join causes duplicate results

Posted 1 year ago by clat23
                $processedSales = Sale::where('sales.user_id', Auth::user()->id)
                    ->where('processed', '=', 1)
                    ->where('sale_date', '>=', Carbon::now()->subDays($numberOfDays))
                    ->join('refunds', 'sales.user_id', '=', 'refunds.user_id')
                    ->orderBy('refunds.status', request('direction'))
                    ->select('sales.*')
                    ->paginate(25);

I'm getting two of each $processedSale. I believe this is happening because of the join. How do I prevent duplicates, or at least filter for uniques?

Please sign in or create an account to participate in this conversation.