Chartjs-Laravel – production.ERROR: Undefined variable: department_chart_data in Chartjs barchart

0👍

Your problem is here:

return view('report.employee_goal_statistics.employee_goals',$department_data);

The second parameter to the view() helper method needs to be an array.

You should be able to resolve the issue by changing to this:

 return view('report.employee_goal_statistics.employee_goals', [
   'department_data' => $department_data,
 ]);

As Daniel Logvin alluded to, the compact() method is commonly used here to remove duplication in setting the array keys, and this should accomplish the same thing:

 return view('report.employee_goal_statistics.employee_goals', compact($department_data));

The view() helper method is discussed a little bit more at https://laravel.com/docs/7.x/views#creating-views

0👍

I know this is too late to answer,but by using laravel 5.8 and this case ,I just think your problem in routing see web.php file careful .

Leave a comment