0
Hello I need to make a select on a table, however if I do not receive the month by the parameter I must do the SUM method to sum all months
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 so above, the Laravel dsconsiders the select within the if
Someone would have a better solution?
1 . What amount is coming in $Month ? 2. From what you say: "receive month by parameter" you could use the isset() function to check this, try a test and see if it works.
– Fernando Souza
Hello. What ended up solving my problem was the hiccup described below, but still thank you
– Laiane Hermes
Laiane has solved his problem accepted as answer to your question!
– novic