public function add() { $fm = Input::get('form'); $an = Input::get('anak'); $jk = Input::get('jenis_kasus'); $ti = Input::get('tindak_lanjut'); $dis = Input::get('disposisi'); $user = Auth::user(); $sign = ['penerima' => $user]; $sign = json_encode($sign); $fm['sign'] = $sign; // 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); $disposisi = DisposisiDAO::saveOrUpdate($dis, $form); $anak = Anak::find($an['id']); //save many to many $form = Form::find($form->id); $form->Anak()->attach($an['id']); $form->user()->attach($user->id); TindakLanjutDAO::attachAll($ti, $anak); JenisKasusDAO::attachAll($jk, $anak); //this part must be write after TindakLanjutDAO::attachAll //and cannot befote TindakLanjutDAO::attahcAll //otherwise it will detach other tindak lanjut if (isset($ti['other']['check'])) { if ($ti['other']['check'] == 1) { TindakLanjutDAO::saveOrUpdate($ti, $anak); } } //this part must be write after JenisKasusDAO::attachAll //and cannot befote JenisKasusDAO::attahcAll //otherwise it will detach other jenis kasus if (isset($jk['other']['check'])) { if ($jk['other']['check'] == 1) { JenisKasusDAO::saveOrUpdate($jk, $anak); } } //notifikasi NotifikasiDisposisiHelper::disposisiCreate($form->id); Session::flash('message', "Form with No LKA {$form->no_lka} has been added!"); // echo "JK<br/>"; // echo "<pre>"; // print_r($jk); // echo "</pre>"; // // echo "Tindak<br/>"; // echo "<pre>"; // print_r($ti); // echo "</pre>"; return Redirect::to('/dash/formka3'); }
public function add() { $fm = Input::get('form'); $an = Input::get('anak'); $jk = Input::get('jenis_kasus'); $int = Input::get('intervensi'); $dis = Input::get('disposisi'); $user = Auth::user(); // 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']); //save many to many $form = Form::find($form->id); $form->Anak()->attach($an['id']); $form->user()->attach($user->id); //this part must be write after JenisKasusDAO::attachAll //and cannot befote JenisKasusDAO::attahcAll //otherwise it will detach other jenis kasus JenisKasusDAO::attachAll($jk, $anak); if (isset($jk['other']['check'])) { if ($jk['other']['check'] == 1) { JenisKasusDAO::saveOrUpdate($jk, $anak); } } IntervensiDAO::attachAll($int, $anak); if (isset($int['other']['check'])) { if ($int['other']['check'] == 1) { IntervensiDAO::saveOrUpdate($int, $anak); } } //notifikasi NotifikasiDisposisiHelper::disposisiCreate($form->id); Session::flash('message', "Form with No LKA {$form->no_lka} has been added!"); return Redirect::to('/dash/formka5'); }