I have a table which stores tips and inside this table is a row of odds.
I need to workout the average odds of all tips
e.g Average Odds = Sum of all odds / Number of Tips
However I cannot workout how to do this in my Controller on Laravel...
I can get total rows with $totaltips = Tip::count();
Laravel has methods for counting and summing: http://laravel.com/docs/4.2/queries.
$tips = Tip::count();
$odds = Tip::sum('your_odds_column');
$average = false;
// Don't divide by zero
if ( $tips > 0 ) {
$average = $odds / $tips;
}