The SQL you want is something like this...
SELECT workplans.division_name, AVG(progress.score) as average_score
FROM `workplans`
LEFT JOIN `progress` ON progress.workplan_id = workplans.id
GROUP BY workplans.id
With the laravel query builder...
$report = DB::table ('workplans')
->join ('progress', 'progress.workplan_id', '=', 'workplans.id')
->select ('workplans.division_name', DB::raw ('AVG(progress.score) as average_score'))
->groupBy ('workplans.id')
->get ();
So for division 1 with scores 5 and 15, division 2 with scores 15 and 25 this returns...
Array
(
[0] => stdClass Object
(
[division_name] => Division 1
[average_score] => 10
)
[1] => stdClass Object
(
[division_name] => Division 2
[average_score] => 20
)
)
The problem with your query is that the avg aggregate function returns the average value for all columns on the table, not a reference back to the query so that you can continue to chain additional functions. The solution to this is to manually specify the average using the MySQL AVG function using the DB::raw method.