HABTM depth find
Hi!
I have:
Fi HABTM Group, User
Group HABTM Fi, User
User HABTM Fi, Group
In my Fi Controller I want to find if a given Fi is associated with a particular user either directly (in fis_users) or indirectly (fis_groups -> group -> groups_users).
Is there an elegant way to do this? If not what's the most straight forward way to do it?
thanks!
Asked by ramam, on 29/1/10
0 Answers
Sorry, but there are no answers yet.
Your Answer
You can use Creole Wiki Syntax to format your text.
Tagged with
Rating
0
Viewed
211 times
Last Activity
on 30/1/10
This is decent solution;
$this->Fi->recursive=3;
$fiData = $this->Fi->read(array('id'), $fi_id);
$users = Set::extract('/User/id', $fiData) + Set::extract('/Group/User/id', $fiData);
$isRelated = Set::contains(array('' => $this->Auth->user('id')));
/* note that is two single quotes with no space between them */
BTW To whom in may concern: I couldn't see how to post this as an answer without creating a new account..
ramam - on 30/1/10