/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate($id) { $model = new GajiPokok(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['GajiPokok'])) { $model->attributes = $_POST['GajiPokok']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id_gaji_pokok)); } } $this->render('create', array('model' => $model, 'id' => $id)); }
/** * Store a newly created resource in storage. * * @return Response */ public function store() { // $data = Input::All(); $data['tanggal_sk'] = formatDate($data['tanggal_sk']); $data['tanggal_mulai'] = formatDate($data['tanggal_mulai']); $data['tanggal_selesai'] = formatDate($data['tanggal_selesai']); $diff = getDateDiff($data['tanggal_mulai'], $data['tanggal_selesai']); if ($diff->y > 0) { $data['masa_kerja'] = $diff->y . ' Tahun ' . $diff->m . ' Bulan'; } $riwayat = new GajiPokok($data); if ($riwayat->save()) { return Response::json(array('success' => true)); } }