If Group belongsTo a User then when you find the group, the user should be
available in the ['User'] array.
i.e.
$note = $this->Group->read(null, $groupId);
assertEquals(isset($note['Group']), true);
assertEquals(isset($note['User']), true);
On Friday, 30 November 2012 03:46:59 UTC+10, Chris wrote:
>
>
> hi guys,... I can't find " GroupUser " association between Models
> can anyone help please,...?
>
> I have a Notification Model:
>
> <?php
> class Notification extends AppModel {
> var $name = 'Notification';
>
> var $validate = array(
> 'user_id' => array(
> 'rule' => 'notEmpty',
> ),
> 'friend_id' => array(
> 'rule' => 'notEmpty',
> ),
> 'photo_id' => array(
> 'rule' => 'notEmpty',
> ),
> 'group_id' => array(
> 'rule' => 'notEmpty',
> ),
> 'blog_id' => array(
> 'rule' => 'notEmpty',
> ),
> );
> var $belongsTo = array(
> 'User' => array('className' => 'User', 'foreignKey' => 'friend_id'),
> 'Photo' => array('className' => 'Photo', 'foreignKey' => 'photo_id'),
> 'Group' => array('className' => 'Group', 'foreignKey' => 'group_id'),
> 'Blog' => array('className' => 'Blog', 'foreignKey' => 'blog_id')
> );
>
> }
> ?>
>
> and Group Model:
>
> <?php
>
> class Group extends AppModel {
> var $name = 'Group';
>
> var $validate = array(
> 'user_id' => array(
> 'rule' => 'notEmpty',
> ),
> 'name' => array(
> 'rule' => 'notEmpty',
> ),
> 'description' => array(
> 'rule' => 'notEmpty',
> ),
> );
> var $belongsTo = array(
> 'User' => array('className' => 'User', 'foreignKey' => 'user_id')
> );
>
> }
> ?>
>
> finding Group is OK,...
> <?php echo $html->link($groupBannerShow->square($note), '/groups/view/' .
> $note['Group']['id'], array('escape'=>false)) ?>
>
> but I also need to find " GroupUser " in a view,...
>
> I'm getting error: Undefined index: GroupUser
>
> <?php echo $html->link($note['GroupUser']['firstname'] . ' ' .
> $note['GroupUser']['lastname'], '/profile/' .
> $note['GroupUser']['username']) ?>
>
> thanks in advance
> chris
>
>
--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
Visit this group at http://groups.google.com/group/cake-php?hl=en.