承接 antonyz89/yii2-templates 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

antonyz89/yii2-templates

Composer 安装命令:

composer require antonyz89/yii2-templates

包简介

minor changes in model/crud templates

README 文档

README

Donate with PayPal

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist antonyz89/yii2-templates dev-master

or add

"antonyz89/yii2-templates": "dev-master"

to the require section of your composer.json file.

Usage

environments/dev/common/config/main

and run php init again

if (!YII_ENV_TEST) {
    // configuration adjustments for 'dev' environment
    $config['bootstrap'][] = 'debug';
    $config['bootstrap'] = ['gii'];
    $config['modules']['debug'] = 'yii\debug\Module';

    $config['modules']['gii'] = [
        'class' => 'yii\gii\Module',
        'generators' => [
            'model' => [
                'class' => 'antonyz89\templates\model\Generator',
                'templates' => [
                    'default' => '@antonyz89/templates/model/default', // add default template
                ]
            ],
            'crud' => [
                'class' => 'antonyz89\templates\crud\Generator',
                'templates' => [
                    'admin-lte' => '@antonyz89/templates/crud/admin-lte', // add admin-lte template
                    'material-lite' => '@antonyz89/templates/crud/material-lite', // add material-lite template
                    'material-bootstrap' => '@antonyz89/templates/crud/material-bootstrap', // add material-bootstrap template
                    'default' => '@antonyz89/templates/crud/default', // add default template
                ]
            ]
        ],
    ];
}

Easy Pjax with _search.php

Kartik GridView ONLY

CRUD generated by Gii with any template already do it, just add YiiTemplateAsset to complete

Usage:

1 - Just add YiiTemplateAsset on YOUR_MODULE/assets/AppAsset

use antonyz89\templates\assets\YiiTemplatesAsset;

class AppAsset extends AssetBundle
{
    public $basePath = '@webroot';
    public $baseUrl = '@web';
    public $css = [];
    public $js = [];
    public $depends = [
        YiiTemplatesAsset::class // ADD
    ];
}

2 - Now, just enable pjax on GridView

GridView::widget([
    'dataProvider' => $dataProvider,
    'pjax' => true, // here
    'columns' => [
        'id',
        'name',
        [
            'class' => 'kartik\grid\ActionColumn',
            'width' => '150px',
            'buttonOptions' => [
                'class' => 'btn btn-sm btn-default'
            ],
            'updateOptions' => [
                'class' => 'btn btn-sm btn-primary'
            ],
            'deleteOptions' => [
                'class' => 'btn btn-sm btn-danger'
            ]
        ]
    ]
]);

3 - Add data-ajax => true on _search's form

<div class="example-search">

    <?php $form = ActiveForm::begin([
        'action' => ['index'],
        'method' => 'get',
        'options' => [
            'data-pjax' => true // HERE
        ],
    ]); ?>

    <div class="row">
        <div class="col-md-1">
            <?= $form->field($model, 'id') ?>
        </div>
        <div class="col-md-5">
            <?= $form->field($model, 'name') ?>
        </div>
    </div>

    <?php ActiveForm::end(); ?>

</div>

DONE!

Just type on _search's fields and GridView will reload

Pjax only from form's submit

To use Pjax only from form's submit, just add 'pjax-only-on-submit' => true on ActiveForm::begin from _search.php

<?php $form = ActiveForm::begin([
        'action' => ['index'],
        'method' => 'get',
        'options' => [
            'data-pjax' => true,
            'pjax-only-on-submit' => true // HERE
        ],
    ]); ?>

ActiveQuery

Alias

Use @alias. on query to replace it with ::tableName or alias.

// Query
User::find()->alias('example')->where(['@alias.name' => 'Antony'])->groupBy('@alias.age');
# result
SELECT `user`.* FROM `user` as `example` WHERE `example`.`name` = 'Antony' GROUP BY `example`.`age`

Disable GROUP BY

set $query->groupBy(false) to disable any GROUP BY on query

统计信息

  • 总下载量: 2.05k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 2
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2020-02-10

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固