/** * Store a newly created resource in storage. * * @return Response */ public function store() { // membuat object baru dari LokasiPelatihan() dengan input nama_lokasi_pelatihan $lokasi_pelatihan = new LokasiPelatihan(); $lokasi_pelatihan->nama_lokasi_pelatihan = Input::get('nama_lokasi_pelatihan'); // bila proses memasukan data berhasil maka akan mengirimkan response dalam bentuk json if ($lokasi_pelatihan->save()) { return Response::json(array('success' => TRUE)); } }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new LokasiPelatihan(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['LokasiPelatihan'])) { $model->attributes = $_POST['LokasiPelatihan']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id_lokasi_pelatihan)); } } $this->render('create', array('model' => $model)); }