Hello, I need to do a select in a table, but if I do not receive the month by the parameter I must do the SUM method to sum every month
if($month != 0){
$dbRegister = tb_data::selectRaw('tb_data.total_points');
}else{
$dbRegister = tb_data::selectRaw('sum(tb_data.total_points)');
}
$dbRegister->selectRaw('TB_USERS.login,TB_USERS.name)->get()
The problem is that if I do this way above, laravel dsconsidera select within the if
Would anyone have a better solution?