public static function update($int, $anak = null) { $inter = Intervensi::find($int['other']['id']); if (isset($int['other']['check'])) { $inter = IntervensiDAO::exchangeArray($inter, $int); $inter->update(); if (!is_null($anak)) { $inter->Anak()->attach($anak->id); } } else { if (!is_null($anak)) { $inter->Anak()->detach($anak->id); } } return $inter; }
public function update() { $fm = Input::get('form'); $an = Input::get('anak'); $jk = Input::get('jenis_kasus'); $int = Input::get('intervensi'); $dis = Input::get('disposisi'); // inject lka if not set if (!isset($fm['no_lka'])) { $form = Anak::find($an['id'])->form->first(); $fm['no_lka'] = $form->no_lka; } // inject tanggal if not set if (!isset($fm['tanggal'])) { $fm['tanggal'] = date('Y-m-d'); } $form = FormDAO::saveOrUpdate($fm); DisposisiDAO::saveOrUpdate($dis, $form); $anak = Anak::find($an['id']); JenisKasusDAO::attachAll($jk, $anak); if ($jk['other']['check'] == 1) { JenisKasusDAO::saveOrUpdate($jk, $anak); } IntervensiDAO::attachAll($int, $anak); if ($int['other']['check'] == 1) { IntervensiDAO::saveOrUpdate($int, $anak); } //save many to many $form = Form::find($form->id); //notifikasi NotifikasiDisposisiHelper::disposisiUpdate($form->id); Session::flash('message', "Form with No LKA {$form->no_lka} has been updated!"); return Redirect::to('dash/formka5'); }