public function store() { $issues = Input::get('issues'); $presences = Input::get('presences'); $descs = Input::get('descs'); if ($this->teached(Input::get('course_id'), Input::get('subject_id'), Input::get('course_date'), Input::get('hour_id'))) { $teach = Teach::where('course_id', '=', Input::get('course_id'))->where('course_date', '=', Input::get('course_date'))->where('hour_id', '=', Input::get('hour_id'))->first(); } else { $teach = new Teach(); $teach->project_id = Auth::user()->curr_project_id; $teach->location_id = Auth::user()->location_id; $teach->course_id = Input::get('course_id'); $teach->employee_id = Input::get('employee_id'); $teach->hour_id = Input::get('hour_id'); $teach->course_date = Input::get('course_date'); $teach->title = Input::get('title'); $teach->comments = Input::get('comments'); $teach->save(); } for ($i = 0; $i < count($issues); $i++) { if (!$this->existed($teach->id, $issues[$i])) { $presence = new Presence(); $presence->project_id = Auth::user()->curr_project_id; $presence->location_id = Auth::user()->location_id; $presence->teach_id = $teach->id; $presence->issue_id = $issues[$i]; $presence->presence = $presences[$i]; $presence->description = $descs[$i]; $presence->save(); } } Session::flash('message', 'Sukses menambahkan pertemuan dan presensi baru'); }