Example #1
0
 public function getListByInstansi($kid, $id = 0)
 {
     $instansi = Instansi::find($id);
     $kelas = Kelas::find($kid);
     $response = [];
     $response['output'] = '';
     $guru = [];
     if ($instansi) {
         $guru = $instansi->guru;
     }
     $data = ['instansi' => $instansi, 'kelas' => $kelas, 'num' => 1, 'guru' => $guru ?: []];
     $response['output'] = view('backend.partials.master.kelas.parlist', $data)->render();
     return response()->json($response);
 }
Example #2
0
 public function responseEdit($id)
 {
     $response = parent::responseEdit($id);
     $validation = $response['validation'];
     unset($response['validation']);
     if ($response['initial'] == true) {
         // Pas form baru kebuka
         $response['errors'] = [];
         $d = Instansi::find($id);
         $response['fields'] = $d->toArray();
         $response['fields']['provinsi_id'] = $d->kota->provinsi_id;
         $response['output'] = view($this->formView, $response)->render();
     } elseif ($validation->passes()) {
         // Pas validasi berhasil
         $response['status'] = true;
         Instansi::addOrModify($response['data'], $id);
     } else {
         // Pas validasi gagal
         $response['fields'] = $response['data'];
         $response['output'] = view($this->formView, $response)->render();
     }
     return $response;
 }