public function destroy($id) { /* memanggil class model Provinsi * lalu melakukan query untuk mengambil data dari DB * dan menghapus datanya */ $provinsi = Provinsi::find($id); $provinsi->delete(); // redirect ke route yang lain return Redirect::to('provinsi')->with('message', 'PROVINSI BERHASIL DIHAPUS'); }
<?php Route::get('api/dropdown', function () { $input = Input::get('option'); $prov = Provinsi::find($input); $kab = $prov->kabupatens(); return Response::make($kab->get(array('id', 'nama'))); }); /** * Frontend Routes * Namespaces indicate folder structure */ Route::group(['namespace' => 'Frontend'], function () { require __DIR__ . "/Routes/Frontend/Frontend.php"; require __DIR__ . "/Routes/Frontend/Access.php"; }); /** * Backend Routes * Namespaces indicate folder structure */ Route::group(['namespace' => 'Backend'], function () { Route::group(['prefix' => 'admin', 'middleware' => 'auth'], function () { /** * These routes need the Administrator Role * or the view-backend permission (good if you want to allow more than one group in the backend, then limit the backend features by different roles or permissions) * * If you wanted to do this in the controller it would be: * $this->middleware('access.routeNeedsRoleOrPermission:{role:Administrator,permission:view_backend,redirect:/,with:flash_danger|You do not have access to do that.}'); * * You could also do the above in the Route::group below and remove the other parameters, but I think this is easier to read here. * Note: If you have both, the controller will take precedence.
$this->params['breadcrumbs'][] = $this->title; /* belum di gunakan karena sudah ada list sidemenu, on plan next*/ $form = ActiveForm::begin(); echo "<h2><b>Origin</b></h2>"; ?> <?php echo $form->field($provinsi, 'PROVINCE')->dropDownList(ArrayHelper::map(Provinsi::find()->asArray()->all(), 'PROVINCE_ID', 'PROVINCE'), ['id' => 'cat-id']); echo $form->field($kota, 'CITY_NAME')->widget(\kartik\depdrop\DepDrop::classname(), ['options' => ['id' => 'subcat-id'], 'pluginOptions' => ['depends' => ['cat-id'], 'placeholder' => 'Select...', 'url' => Url::to(['/send/get-kota'])]]); ?> <?php echo "<h2><b>Destination</b></h2>"; ?> <?php $Expired = Provinsi::find()->all(); $listData = ArrayHelper::map($Expired, 'PROVINCE_ID', 'PROVINCE'); // echo $form->field($model, 'province')->dropDownList($listData, ['id'=>'id-province']); // echo $form->field($model, 'provinsi')->dropDownList($listData); echo $form->field($provinsi, 'PROVINCE')->dropDownList($listData, ['prompt' => '-Choose a provinsi-', 'onchange' => ' $.post( "index.php?r=send/lists&id=' . '"+$(this).val(), function( data ) { $( "select#kota-city_name" ).html( data ); }); ']); ?> <?php $dataPost = ArrayHelper::map(Kota::find()->all(), 'CITY_ID', 'CITY_NAME'); echo $form->field($kota, 'CITY_NAME')->dropDownList($dataPost); ?> <?php ActiveForm::end();