goodizer/yii2-helpers

An advanced Yii 2 helpers.

v1.4.0 2018-06-03 22:29 UTC

This package is auto-updated.

Last update: 2024-05-11 22:50:52 UTC


README

Latest Stable Version License Total Downloads Monthly Downloads Daily Downloads

Installation

The preferred way to install this extension is through composer.

Note: Check the composer.json for this extension's requirements and dependencies.

Either run

$ php composer.phar require goodizer/yii2-helpers

or add

"goodizer/yii2-helpers": "*"

to the require section of your composer.json file.

Usage

GridSearchHelper

Create ActiveDataProvider object and build query by GET|POST data validated in model, which will be in filterModel property for GridView, ListView, etc.

use goodizer\helpers\GridSearchHelper;
use yii\grid\GridView;

$searchData = GridSearchHelper::search(new Note());
echo GridView::widget([
	'columns' => [
		'id',
		'name',
		'etc',
	],
    'filterModel' => $searchData->filterModel,
    'dataProvider' => $searchData->dataProvider,
]);

DbSyncHelper

Create or modify tables by model attribute types. Also can add CONSTRAINT REFERENCES.

use goodizer\helpers\DbSyncHelper;

$sync = new DbSyncHelper([
  'common\models',
  'modules\admin\models',
  'some\another\namespace',
]);
$sync->run();