Graph for parent-child representation relations on self-relates activeRecord
i.e. for next composition, (*1)
/**
* @property MainModel[] $parents
* @property MainModel[] $childs
*/
class MainModel extends \yii\db\ActiveRecord
{
var $id;
}
/**
* @property MainModel $parent
* @property MainModel $child
*/
class RelationModel extends \yii\db\ActiveRecord
{
var $parentId;
var $childId;
}
via table property can be prefixed parent
, child
, can accept complex pk;, (*2)
graphical representation and actions:, (*3)
, (*4)
similar at githubjeka/yii2-gui-rbac, (*5)
, (*6)
How to install
Follow the commands:
- Add to your composer.json "bscheshirwork/yii2-gui-acyclic-graphs": "*@dev"
- Run composer update
- Add to config
the code:, (*7)
// '/config/web.php' for Basic or '/backend/config/main' - Advanced Yii2 application.
'modules' => [
'gui' => [
'class' => 'bscheshirwork\gui\Module',
'as access' => [ // if you need to set access
'class' => 'yii\filters\AccessControl',
'rules' => [
[
'allow' => true,
'roles' => ['@'] // all auth users
],
],
],
'mainModel' => 'common\models\MainModel', // model, who have relations. (rectangles)
'mainModelFormView' => '@backend/views/main-model/_form-gui', //Active form for MainModel. See @vendor/bscheshirwork/yii2-gui-acyclic-graphs/src/views/default/_form
'relationModel' => 'common\models\RelationModel', // via model (arrows)
'arrowDirection' => bscheshirwork\gui\Module::PARENT_TO_CHILD, // direction of arrow representation
],
],
- go to url
/index.php?r=gui