2017 © Pedro Peláez
 

library yii-behaviors

Useful behaviors for ActiveRecord.

image

ruvents/yii-behaviors

Useful behaviors for ActiveRecord.

  • Wednesday, November 8, 2017
  • by RUVENTS
  • Repository
  • 3 Watchers
  • 0 Stars
  • 1,269 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 13 Versions
  • 7 % Grown

The README.md

yii-behaviors

License, (*1)

Коллекция поведений для Yii 1.x ActiveRecord моделей., (*2)

Использование

Добавить в composer.json зависимость:, (*3)

"vizh/yii-behaviors": "0.0.6"

Миграции

Создание новой таблицы

$tableSchema = [
    'Id' => 'serial primary key',
    'PostId' => 'integer not null',
    'UserId' => 'integer not null',
    'Name' => 'varchar(1000) not null',
    'Body' => 'text not null'
];

$tableSchema = array_merge($tableSchema, DeletableBehavior::getMigrationFields());
$tableSchema = array_merge($tableSchema, UpdatableBehavior::getMigrationFields());

$this->createTable('BlogPost', $tableSchema);

Добавление полей в существующую таблицу

foreach (DeletableBehavior::getMigrationFields() as $column => $type) {
    $this->addColumn('BlogPost', $column, $type);
}

Конфигурация модели

public function behaviors()
{
    return [
        ['class' => 'UpdatableBehavior'],
        ['class' => 'DeletableBehavior'],
        ['class' => 'AttributableBehavior', 'attribute' => 'Attributes']
    ];
}

Для корректной работы AttributableBehavior необходимо завести в модели ActiveRecord публичное свойство, названное аналогично значению параметра 'attribute' настроек поведения. Удобства ради, можно "пробросить" следующие методы в модель:, (*4)

/*
 * Методы AttributableBehavior
 * @method Role byAttribute($attribute, $value)
 * @method Role byAttributeExists($attribute)
 * @method Role byAttributeSearch($attribute, $value)
 */

The Versions

08/11 2017

dev-uploadablebehavior-thumbnail

dev-uploadablebehavior-thumbnail

Useful behaviors for ActiveRecord.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Maksim Makhniuk

08/11 2017

0.0.12

0.0.12.0

Useful behaviors for ActiveRecord.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Maksim Makhniuk

19/10 2017

dev-master

9999999-dev

Useful behaviors for ActiveRecord.

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

by Maksim Makhniuk

19/10 2017

0.0.11

0.0.11.0

Useful behaviors for ActiveRecord.

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

by Maksim Makhniuk

18/10 2017

0.0.10

0.0.10.0

Useful behaviors for ActiveRecord.

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

by Maksim Makhniuk

27/09 2017

0.0.9

0.0.9.0

Useful behaviors for ActiveRecord.

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

by Maksim Makhniuk

06/09 2017

0.0.8

0.0.8.0

Useful behaviors for ActiveRecord.

  Sources   Download

MIT

The Requires

 

by Maksim Makhniuk

05/09 2017

17.x-dev

17.9999999.9999999.9999999-dev

Useful behaviors for ActiveRecord.

  Sources   Download

MIT

The Requires

 

by Maksim Makhniuk

05/09 2017

0.0.7

0.0.7.0

Useful behaviors for ActiveRecord.

  Sources   Download

MIT

The Requires

 

by Maksim Makhniuk

20/08 2017

0.0.6

0.0.6.0

Useful behaviors for ActiveRecord.

  Sources   Download

MIT

The Requires

 

by Maksim Makhniuk

14/08 2017

0.0.3

0.0.3.0

Useful behaviors for ActiveRecord.

  Sources   Download

MIT

The Requires

 

by Maksim Makhniuk

12/08 2017

0.0.2

0.0.2.0

Useful behaviors for ActiveRecord.

  Sources   Download

MIT

The Requires

 

by Maksim Makhniuk

12/08 2017

0.0.1

0.0.1.0

Useful behaviors for ActiveRecord.

  Sources   Download

MIT

The Requires

 

by Maksim Makhniuk