PHP code example of zlakomanoff / yii2-related-entities

1. Go to this page and download the library: Download zlakomanoff/yii2-related-entities 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/ */

    

zlakomanoff / yii2-related-entities example snippets


php composer.phar 

 $form = \zlakomanoff\relatedentities\RelatedActiveForm::begin(); 

class MyRecord extends \zlakomanoff\relatedentities\RelatedActiveRecord
{

    public function rules()
    {
        return [
            [['field1', 'field2'], 'relation']
        ];
    }

    public function getField1()
    {
        return $this->hasMany(MyField1::class, ['id' => 'field1_id']);
    }

    public function getField2()
    {
        return $this->hasMany(MyField2::class, ['id' => 'field2_id']);
    }

}