Ejemplo n.º 1
0
 protected function createGoal($year)
 {
     Store::findActive()->get()->each(function ($store) use($year) {
         for ($month = 1; $month <= 12; $month++) {
             $goal = StoreGoal::findByStore($store)->findByYear($year)->findByMonth($month)->first();
             if (!$goal) {
                 $goal = new StoreGoal();
                 $goal->store_id = $store->id;
                 $goal->year = $year;
                 $goal->month = $month;
                 $goal->save();
             }
         }
     });
 }