Skip to content

ruslanbelziuk/yii-eav

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 

Repository files navigation

yii-eav

Installation

  1. Create EAV tables in your database with (can be found in eav.sql).

  2. Add behavior and relation to your model.

     public function behaviors()
     {
         return array(
             ...
             'eav'=>array(
                 'class'=>'EavBehavior'
             )
             ...
         );
     }
    
     public function relations()
     {
         ...
         return array(
             'attributeValues' => array(self::HAS_MANY, 'EavAttributeValue', 'object_id', 'on' => 'attributeValues.object_entity="'.get_class($this).'"'),
         );
         ...
     }
    
  3. Assign POST field while creating or updating the model. Be sure to save the object before setting values to EAV variables while creating.

         $client->save();
         ...
         $client->eavAttributes = $_POST['ClientAttribute'];
         $client->save();
    

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published