public function store($groupId) { $date = Input::get('date'); $time = Input::get('time'); try { DB::transaction(function () use($groupId, $date, $time) { foreach (Input::get('customers') as $customerId) { $att = new \App\Attendance(['group_id' => $groupId, 'customer_id' => $customerId, 'was_at' => sprintf('%s %s', $date, $time)]); $att->save(); } }); } catch (Exception $e) { redirect(route('attendance.index', $groupId))->with('error', $e->getMessage()); } return redirect(route('attendance.index', $groupId))->with('status', 'Attendance saved'); }