Skip to content

Instantly share code, notes, and snippets.

View DeaVenditama's full-sized avatar

Dea Venditama DeaVenditama

View GitHub Profile
@DeaVenditama
DeaVenditama / db.php
Created December 5, 2019 08:11
config/db.php
<?php
return [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=localhost;dbname=simpeg',
'username' => 'root',
'password' => '',
'charset' => 'utf8',
// Schema cache options (for production environment)
@DeaVenditama
DeaVenditama / index.php
Created December 5, 2019 08:18
views/pegawai/index.php
<?php
use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel app\models\PegawaiSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Pegawai';
@DeaVenditama
DeaVenditama / content.php
Created December 5, 2019 08:20
views/layouts/content.php
<?php
use yii\widgets\Breadcrumbs;
use dmstr\widgets\Alert;
?>
<div class="content-wrapper">
<?=
Breadcrumbs::widget(
[
'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
@DeaVenditama
DeaVenditama / helper.php
Created December 5, 2019 08:23
simpeg part 1. components/helper.php
<?php
namespace app\components;
use Yii;
use yii\base\Component;
class helper extends Component{
private $agama = [
'1' => 'Islam',
'2' => 'Kristen Protestan',
@DeaVenditama
DeaVenditama / _form.php
Created December 5, 2019 08:24
simpeg part 1.views/pegawai/_form.php
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\jui\DatePicker;
/* @var $this yii\web\View */
/* @var $model app\models\Pegawai */
/* @var $form yii\widgets\ActiveForm */
?>
@DeaVenditama
DeaVenditama / PegawaiController.php
Created December 5, 2019 08:27
Simpeg part 1.action create PegawaiController.php
public function actionCreate()
{
$model = new Pegawai();
if ($model->load(Yii::$app->request->post())) {
$model->created_date = date('Y-m-d H:i:s');
$model->created_by = 0;
$model->save();
return $this->redirect(['view', 'id' => $model->id]);
@DeaVenditama
DeaVenditama / Pegawai.php
Created December 5, 2019 08:28
simpeg part1. models/Pegawai.php
<?php
namespace app\models;
use Yii;
/**
* This is the model class for table "pegawai".
*
* @property int $id
@DeaVenditama
DeaVenditama / view.php
Created December 5, 2019 08:30
simpeg part1.views/pegawai/view.php
<?php
use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model app\models\Pegawai */
$this->title = $model->nama;
$this->params['breadcrumbs'][] = ['label' => 'Pegawais', 'url' => ['index']];
@DeaVenditama
DeaVenditama / helper.php
Created December 5, 2019 08:32
simpeg part1. tambahan helper
public function getAgama($id)
{
return $this->agama[$id];
}
public function getJenisKelamin($id)
{
return $this->jenisKelamin[$id];
}
@DeaVenditama
DeaVenditama / update.php
Created December 5, 2019 08:33
simpeg part1. views/pegawai/update.php
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model app\models\Pegawai */
$this->title = 'Update Pegawai: ' . $model->nama;
$this->params['breadcrumbs'][] = ['label' => 'Pegawai', 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->id, 'url' => ['view', 'id' => $model->id]];