FareedR
2 months ago
700
10
Laravel

How can I ignore data that equal with another field ?

Posted 2 months ago by FareedR
// controller
$loss_stocks            = Stock::where('profit','>','0')->orderBy('profit','desc')->get();
$loss_stocks            = Stock::where('loss','>','0')->orderBy('loss','desc')->get();

// database

id | profit | loss | name |
1	1		1	abc
2	0		1	abcd
2	1		0	abcde

//expected result
Profit = abcde
Loss   = abcd

//current result
Profit = abc , abcde
Loss   = abc, abcd, abcde

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