Advertisement
Apidcloud

YiiModels

Feb 4th, 2016
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.98 KB | None | 0 0
  1. // Inspecao Model
  2. public function relations()
  3.     {
  4.         return array(
  5.             'unidade' => array(self::BELONGS_TO, 'Unidade', 'unidade_id')
  6.         );
  7.  
  8.         /* I was trying to access 'Kit' from here, as so:
  9.        
  10.         return array(
  11.             'unidade' => array(self::BELONGS_TO, 'Unidade', 'unidade_id'),
  12.             'em_kit'=>array(self::HAS_MANY,'EmKit',array('id'=>'unidade_id'),'through'=>'unidade'),
  13.             'kit'=>array(self::BELONGS_TO,'Kit','kit_id','through'=>'em_kit')
  14.         );
  15.  
  16.         */
  17.     }
  18.  
  19. // Unidade Model
  20. public function relations()
  21.     {
  22.         return array(
  23.             'inspecoes'=>array(self::HAS_MANY, 'Inspecao', 'unidade_id'),
  24.             'em_kit'=>array(self::HAS_ONE, 'EmKit', 'unidade_id'),
  25.         );
  26.     }
  27.  
  28. // EmKit Model
  29. public function relations()
  30.     {
  31.         return array(
  32.             'unidade' => array(self::BELONGS_TO,'Unidade', 'unidade_id'),
  33.             'kit' => array(self::BELONGS_TO,'Kit', 'kit_id'),
  34.         );
  35.     }
  36.  
  37. // Kit Model
  38. public function relations()
  39.     {
  40.         return array(
  41.             'unidades'=>array(self::HAS_MANY, 'EmKit', 'kit_id'),
  42.         );
  43.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement