public static function update($kl, $anak = null) { $keluarga = Keluarga::find($kl['id']); $keluarga = KeluargaDAO::exchangeArray($keluarga, $kl); if (!is_null($anak)) { $keluarga->Anak()->associate($anak); } $keluarga->update(); return $keluarga; }
public function delete($id) { //notifikasi FormKA4DisposisiHelper::deleteNotif($id); $fm = Form::find($id); $anakId = 64; $anak = Anak::find($anakId); $forms = $anak->form; //delete semua form yang berkaitan foreach ($forms as $form) { if ($form->nama == "ka4" || $form->nama == "ka5" || $form->nama == "ka6" || $form->nama == "ka7") { FormDAO::delete($form->id); } } //delete data pendampingan $pendamping = $anak->Pendampingan()->get(); foreach ($pendamping as $pd) { PendampinganDAO::delete($pd->id); } $gf = $anak->GambaranFisik()->get(); foreach ($gf as $val) { GambaranFisikDAO::delete($val->id); } $kp = $anak->KondisiPsikososial()->get(); foreach ($kp as $val) { KondisiPsikososialDAO::delete($val->id); } $im = $anak->IdentifikasiMasalah()->get(); foreach ($im as $val) { IdentifikasiMasalahDAO::delete($val->id); } $kel = $anak->Keluarga()->get(); foreach ($kel as $val) { KeluargaDAO::delete($val->id); } if ($fm) { Session::flash('message', "Form with {$id} has been deleted!"); } else { Session::flash('message', "Error, Form with {$id} not found!"); } return Redirect::to('/dash/formka4'); }