Skip to content

Instantly share code, notes, and snippets.

View calcio's full-sized avatar

Cálcio calcio

View GitHub Profile
@calcio
calcio / detailView.php
Created March 4, 2017 18:54
Example of GridView and DetailView in Yii 2
<?= DetailView::widget([
'model' => $model,
'template' => '<tr><th class="col-sm-2">{label}</th> <td>{value}</td></tr>',
'attributes' => [
'full_name',
'date_born:date',
'address',
[
'attribute' => 'sex',
'value' => ($model->sex === 1) ? 'Male' : 'Female',
@calcio
calcio / m170104_184151_users.php
Created March 24, 2017 12:36
Migrate example - serie Vitrine project
<?php
use yii\db\Migration;
class m170104_184151_users extends Migration
{
public function up()
{
$tableOptions = null;
if ($this->db->driverName === 'mysql') {
<?php
use yii\db\Migration;
/**
* Handles the creation of table `about`.
*/
class m170203_135420_create_about_table extends Migration
{
/**
<?php
use yii\db\Migration;
/**
* Handles the creation of table `category`.
*/
class m170203_135455_create_categories_table extends Migration
{
/**
<?php
use yii\db\Migration;
/**
* Handles the creation of table `products`.
* Has foreign keys to the tables:
*
* - `category`
*/
<?php
use yii\db\Migration;
/**
* Handles the creation of table `product_images`.
*/
class m170317_124609_create_product_images_table extends Migration
{
/**
@calcio
calcio / web.php
Created December 9, 2017 09:26
Registering module admin in vitrine project
<?php
$params = require(__DIR__ . '/params.php');
$config = [
'id' => 'vitrine',
'basePath' => dirname(__DIR__),
'bootstrap' => ['log'],
'language' => 'pt-br',
'timezone' => 'America/Sao_Paulo',
@calcio
calcio / AdminAsset.php
Created December 18, 2017 23:02
Asset bundle do módulo admin
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace app\assets;
use yii\web\AssetBundle;
@calcio
calcio / backend.php
Created December 20, 2017 22:41
template backend projeto vitrine
<?php
/* @var $this \yii\web\View */
/* @var $content string */
use yii\helpers\Html;
use yii\bootstrap\Nav;
use yii\bootstrap\NavBar;
use yii\widgets\Breadcrumbs;
use app\assets\AdminAsset;
@calcio
calcio / modules\admin\controllers\DefaultController.php
Created January 18, 2018 22:54
Vitrine - Module Admin - DefaultController.php
<?php
namespace app\modules\admin\controllers;
use Yii;
use yii\web\Controller;
use yii\filters\VerbFilter;
use yii\filters\AccessControl;
use app\modules\admin\models\LoginForm;