/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { // $keluarga = Keluarga::find($id); if ($keluarga->delete()) { return Response::json(array('success' => TRUE)); } }
/** * Updates a particular model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id the ID of the model to be updated */ public function actionUpdate($id) { /*$model=$this->loadModel($id); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if(isset($_POST['Siswa'])) { $model->attributes=$_POST['Siswa']; if($model->save()) $this->redirect(array('view','id'=>$model->nis)); } $this->render('update',array( 'model'=>$model, ));*/ $model = $this->loadModel($id); $model2 = Keluarga::model()->findByPk($model->no_kk); $model3 = Ayah::model()->findByPk($model2->nik_ayah); $model4 = Ibu::model()->findByPk($model2->nik_ibu); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Siswa'])) { $model4->attributes = $_POST['Ibu']; $model3->attributes = $_POST['Ayah']; $model2->attributes = $_POST['Keluarga']; $model->attributes = $_POST['Siswa']; $valid = $model->validate(); $valid = $model4->validate() && $valid; $valid = $model3->validate() && $valid; $valid = $model2->validate() && $valid; if ($valid) { $model4->save(); $model3->save(); $model2->save(); if ($model->save()) { $this->redirect(array('view', 'id' => $model->nis)); } } } $this->render('update', array('model' => $model, 'model2' => $model2, 'model3' => $model3, 'model4' => $model4)); }
public function getKeluarga($id = null) { $data = array('field' => array('nama_anggota_keluarga', 'tanggal_lahir', 'status_kawin', 'pekerjaan'), 'values' => Keluarga::orderBy('nama_anggota_keluarga')->where('id_pegawai', '=', $id)->get()); return Response::json($data); }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = Keluarga::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
<?php $this->breadcrumbs = array('Siswas' => array('index'), $model->nis); $this->menu = array(array('label' => 'Daftar Siswa', 'icon' => 'icon-list-alt', 'url' => array('index')), array('label' => 'Tambah Siswa', 'icon' => 'icon-plus-sign', 'url' => array('create')), array('label' => 'Ubah Siswa', 'icon' => 'icon-edit', 'url' => array('update', 'id' => $model->nis)), array('label' => 'Hapus Siswa', 'icon' => 'icon-remove', 'url' => '#', 'linkOptions' => array('submit' => array('delete', 'id' => $model->nis), 'confirm' => 'Apakah anda yakin akan menghapus data ini?')), array('label' => 'Kelola Siswa', 'icon' => 'icon-th', 'url' => array('admin'))); ?> <?php $box = $this->beginWidget('bootstrap.widgets.TbBox', array('title' => 'VIEW BIODATA SISWA ' . strtoupper($model->nama_lengkap), 'headerIcon' => 'icon-picture')); ?> <?php $this->widget('bootstrap.widgets.TbDetailView', array('data' => $model, 'attributes' => array(array('label' => '', 'type' => 'raw', 'value' => Chtml::image(Yii::app()->request->baseUrl . '/images/' . $model->foto, 'DORE', array("width" => 100))), 'nis', 'nama_lengkap', 'nama_panggilan', 'jk', 'tempat_lahir', 'tanggal_lahir', 'anak_ke', 'status', 'jml_saudara', 'alamat', 'no_telp', 'agama', 'kewarganegaraan', 'bahasa', 'jarak_rumah', 'th_ajar', 'semester', 'idkec0.nama_kec', 'idSekolah.nama_sekolah', 'nik_wali', 'no_kk', 'no_pendaftaran', 'nisn'))); $this->widget('bootstrap.widgets.TbDetailView', array('data' => Keluarga::model()->findByPk($model->no_kk), 'attributes' => array('nikAyah.nama_ayah', 'nikIbu.nama_ibu'))); $this->endWidget();