Skip to content

Instantly share code, notes, and snippets.

View mdmunir's full-sized avatar

Misbahul D Munir mdmunir

View GitHub Profile
{{ register_asset_bundle('app/assets/AppAsset') }}
{{ void(this.beginPage()) }}
<!DOCTYPE html>
<html lang="{{ app.language }}">
<head>
<meta charset="{{ app.charset }}">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{{ html.encode(this.title) }}</title>
{{ html.csrfMetaTags | raw }}
{{ void(this.head()) }}
<?php
namespace app\controllers;
use Yii;
use yii\web\Controller;
/**
* Site controller
*/
<?php
return [
'vendorPath' => dirname(dirname(__DIR__)) . '/vendor',
'basePath' => dirname(__DIR__),
'components' => [
'cache' => [
'class' => 'yii\caching\FileCache',
],
],
];
{
"name": "demo/my-yii2-app",
"minimum-stability": "dev",
"require": {
"php": ">=5.4.0",
"yiisoft/yii2": "~2.0"
},
"config": {
"process-timeout": 1800
},
@mdmunir
mdmunir / subquery.php
Last active April 8, 2016 06:48
Sub Query
<?php
$queryGM = (new Query())
->select(['gmd.product_id', 'total' => 'sum(gmd.qty)'])
->from(['gm' => '{{%goods_movement}}'])
->innerJoin(['gmd' => '{{%goods_movement_dtl}}'], '[[gmd.movement_id]]=[[gm.id]]')
->where(['gm.status' => 20, 'gm.reff_type' => self::REFF_SELF, 'gm.reff_id' => $this->id])
->groupBy(['gmd.product_id']);
$queryItem = (new Query())
->select(['md.product_id', 'md.cogs', 'md.qty', 'md.uom_id', 'g.total'])
class Contact extends Model
{
public function rules()
{
return [
// name, email, subject and body are required
[['name', 'email', 'subject', 'body'], 'required'],
// email has to be a valid email address
['email', 'email'],
// verifyCode needs to be entered correctly
<!DOCTYPE html>
<html>
<head>
<title><?= get('title') ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet">
<script type="text/javascript" src="//code.jquery.com/jquery-2.1.1.min.js"></script>
</head>
<body>
<div class="wrap">
<?php
define('APP_PATH', __DIR__);
define('SYS_GLOBAL_VAR', '_d326_fw');
session_start();
function set($name, $value)
{
$GLOBALS[SYS_GLOBAL_VAR][$name] = $value;
}
@mdmunir
mdmunir / _form.php
Created March 20, 2016 09:51
Contoh Tabular Input
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use mdm\widgets\GridInput;
/* @var $this yii\web\View */
/* @var $model app\models\Order */
/* @var $form yii\widgets\ActiveForm */
?>
@mdmunir
mdmunir / Action.php
Created June 23, 2015 22:41
Menghitung waktu shalat
public function actionImsakiyah()
{
$model = new \app\models\Imsakiyah();
$jadwal = null;
if ($model->load(\Yii::$app->request->get(), '') && $model->validate()) {
$jadwal = $model->getImsakiyah();
}
return $this->render('imsakiyah', ['model' => $model, 'jadwal' => $jadwal]);
}