I think the point is that as part of your log in process you scrape information 
from your associated model and add it to the User array. You could also do an 
update if the associated model data was changed, I guess.

Jeremy Burns
jeremybu...@me.com


On 7 Jun 2010, at 19:33, saidbakr wrote:

> I also noticed another thing:
> 
> The output of $this->Auth->user() ,without key parameter, is an array
> which is listing User model only without regarding the associated
> model.
> 
> 
> Array ( [User] => Array ( [id] => 1 [username] => admin [name] => Said
> Bakr [join_date] => 2010-06-14 19:35:00 [email] => said....@gmail.com
> [rule_id] => 1 ) )
> 
> On Jun 7, 8:27 pm, cricket <zijn.digi...@gmail.com> wrote:
>> On Jun 7, 11:39 am, saidbakr <said....@gmail.com> wrote:
>> 
>> 
>> 
>>> Hi,
>> 
>>> I use User model to handle user's basic data such as Name, username,
>>> password and so on.
>> 
>>> The User model is associated with Rule model by belongsTo association,
>>> while Rule model is associated to User model by hasMany association.
>> 
>>> The later model "Rule" is meant by something like users groups so it
>>> handles name, description, value and of-course id, for example, two
>>> records from rules table:
>> 
>>> id -> 1
>>> name -> Administrators
>>> description -> The super users group!
>>> value -> ABC
>> 
>>> id -> 2
>>> name -> Editors
>>> decription -> reviewers and articles writers.
>>> value -> BC
>> 
>>> In AuthComponent documentation 
>>> :http://book.cakephp.org/view/247/AuthComponent-Methods#user-387
>> 
>>> when they talked about "user" method of the component, they regards
>>> that it is possible to retrieve the current user data from the session
>>> in the view like:
>> 
>>> # $session->read('Auth.User.first_name') //returns particular field
>>> value
>> 
>>> This example shows that the access of User model property first_name.
>> 
>>> My Question Is,
>> 
>>> How could I able to access the associated model property "Rule" such
>>> as Rule.name ?
>> 
>>> Best Regards!
>> 
>> You should implement a login() method in your UsersController. In
>> there, do something like:
>> 
>> $this->Session->write('Auth.User.foo', 'bar');
>> 
>> When you need to read the info:
>> 
>> echo $this->Auth->user('foo');
>> 
>> Basically, Auth::user() simply reads whatever data has been written to
>> the Session's 'Auth.User' key (note the uppercase U). You can also
>> write entire arrays:
>> 
>> $this->Session->write('Auth.User.extra', array('foo' => 'bar'));
> 
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
> 
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to