2017 © Pedro Peláez
 

yii2-extension yii2-link-relative

image

mrssoft/yii2-link-relative

  • Friday, May 25, 2018
  • by mrs2000
  • Repository
  • 1 Watchers
  • 0 Stars
  • 2 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

yii2-link-relative

Installation

The preferred way to install this extension is through composer., (*1)

Either run, (*2)

php composer.phar require --prefer-dist mrssoft/yii2-link-relative "*"

or add, (*3)

"mrssoft/yii2-link-relative": "*"

to the require section of your composer.json file., (*4)

Usage

Виджет:, (*5)

    echo LinkRelativeWidget::widget([
        'model' => $model, //Базовая модель
        'relationName' => 'items', //Название отношения (конечного)
        'attributeTitle' => 'title', //Атрибут для вывода в таблице
        'viaToElementName' => 'item',
        'ajaxUrl' => ['item/search'], //Ссылка на поиск элементов
        'placeholder' => 'Поиск товара...',
        'name' => 'Товар' //Название элементов в таблице
    ]);

Поведение базовой модели:, (*6)

    public function behaviors()
    {
        return [
            [
                'class' => SaveRelationBehavior::class,
                'relationName' => 'items'
            ],
        ];
    }

Действие для поиска элементов:, (*7)

    public function actionSearch($search = null)
    {
        $out = ['results' => ['id' => '', 'text' => '']];

        if ($search !== null) {
            $data = Item::find()
                        ->select(['CONCAT(`type`, " ", `name`) as text', 'id'])
                        ->andWhere(['like', 'name', $search])
                        ->orWhere(['like', 'type', $search])
                        ->orderBy('text')
                        ->limit(20)
                        ->asArray()
                        ->all();
            $out['results'] = array_values($data);
        }

        Yii::$app->response->format = Response::FORMAT_JSON;
        return $out;
    }

The Versions

25/05 2018

dev-master

9999999-dev

  Sources   Download

MIT

The Requires

 

by Melnikov Ruslan

orm extension yii2

25/05 2018

1.0.0

1.0.0.0

  Sources   Download

MIT

The Requires

 

by Melnikov Ruslan

orm extension yii2