protected function getGoalGroups($year) { $goalGroups = []; for ($month = 1; $month <= 12; $month++) { $goalGroups[$month] = StoreGoal::with(['store'])->findByYear($year)->findByMonth($month)->get()->sortBy(function ($goal) { return $goal->store->sn; }); } return $goalGroups; }
/** * 取得目前月份的目標(201601) * * @return array */ protected function getConfig($export) { $goalWithSnKey = []; $goals = StoreGoal::with(['store'])->findByYear($export->getDate()->format('Y'))->findByMonth($export->getDate()->format('m'))->get(); foreach ($goals as $goal) { $goalWithSnKey[$goal->store->sn] = ['name' => $goal->store->name, 'goal' => $goal->origin_goal, 'pl' => $goal->pl_origin_goal]; } return $goalWithSnKey; }