Monday, November 5, 2012

Passing variables between AppController and Models / Access Auth data in Models

Hi all !

I need to implement a little complex user permissions over data in tables :

relations are similar to the following :

- user belongs to a customer
- book belongs to a customer

In order to keep it DRY and "fat model / slim controller", I thought I could just add something like :

// Book Model
$queryData['conditions']['customer_id']=$this->Auth->User['customer_id'];

But, I don't get how to access Auth parameters from the models.

The only way I found to pass this barrier is to send the user's customer_id via the $_SESSION which is quite .. err .. ugly :)

Any suggestions on how to pass parameters to all models ?

Note that I need the customer_id available for all models, not just "Book" ..

--
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 cake-php@googlegroups.com.
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 

No comments: