PHP code example of ruvents / yii-behaviors

1. Go to this page and download the library: Download ruvents/yii-behaviors library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ruvents / yii-behaviors example snippets


$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
 * @method Role byAttribute($attribute, $value)
 * @method Role byAttributeExists($attribute)
 * @method Role byAttributeSearch($attribute, $value)
 */