How to do a select depending on some conditions that comes by parameters in laravel 4.2?

1

My problem is as follows ....

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

When the month does not come I need to make 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 leave the separate select this way it does not work. Could someone tell me?

Thank you: D

    
asked by anonymous 26.01.2018 / 11:32

0 answers