I need to optimize this in the model
public function getPointStatsByUserId($id){
return array(
'total_win' => Trade::where('point' , '>', '0')
->where('user_id' , $id)
->sum('point'),
'total_lose' => Trade::where('point' , '<', '0')
->where('user_id' , $id)
->sum('point')
);
}
You are making 2 queries to the database, I would like to know if it is possible to do it in just one query ... Thanks.