1. Go to this page and download the library: Download macfly/yii2-taxonomy 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/ */
use macfly\taxonomy\behaviors\PropertyTermBehavior;
/**
* ...
* @property array $terms
* @property array $envs
*/
class Post extends \yii\db\ActiveRecord
{
public function behaviors()
{
return [
PropertyTermBehavior::className(),
...
],
];
}
# Define the get method of property 'env'
public function getEnvs()
{
return $this->getPropertyTerms('env');
}
# Define the set method of property 'env'
public function setEnvs($terms)
{
return $this->setPropertyTerms('env', $terms);
}
# Add term by name and value
public function addEnv($name, $value)
{
return $this->addPropertyTerm('env', $name, $value);
}
# Detach term by name and value
public function delEnv($name, $value)
{
return $this->delPropertyTerm('env', $name, $value);
}
# Has term by name and value
public function hasEnv($name, $value)
{
return $this->hasPropertyTerm('env', $name, $value);
}
}