How to make a select depending on some conditions that comes by parameters in Laravel 4.2?

Asked

Viewed 33 times

1

My problem is this....

I have a route that receives the year and month to seek some information in the bank.

When the month doesn’t come I need to be made the sum of all the months of the requested year.

if($month == 0){
    $dbRegister = DB::table('tb_data')->select(DB::raw("SUM(tb_data.total_points) as total_points"));
}else{
     $dbRegister = DB::table('tb_data')->select('tb_data.total_points');
}

$dbRegister->select(DB::raw('tb_data.user)....

If I let select separate that way it doesn’t work. Someone would tell me?

Thank you :D

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.