Hi,
Over the past year I have built a very unwieldy complex event management
system for an education science festival as my first CakePHP project but I
am having trouble getting my head around what is probably a very basic
CakePHP problem. I may even be going about this completely the wrong way.
To simplify, I have 3 models - *Event, Request *and *User*.
*Users* have 3 roles - *Admin*, *Schools* and *Provider*.
*Providers* offer events and *Schools *can request them, with details
stored in the related tables. *Admins w*ould then check them over and click
'Accept' to then forward the *Schools* info to the *Providers *etc.
Now, as both *Providers* and *Schools* are *Users*, and as I can only have
one user_id field in my *Requests* table, I called the *Providers* field
providers_id
The problem is that when I'm trying to output a list of *Request *data to
my view (on screen and via CSV file) with the *Providers* details and
*Schools* details, it can't pull anything for the *Providers *but their ID.
How do I get their details into the data I'm sending to my view?
I've tried the following Hash function but it puts the required details of
the provider from the last row into ALL the rows. I tried it without the {n}
expression
and it just throws an error.
Many thanks,
MarkB.
$requests = $this->Request->find('all');
foreach ($requests as $row):
$provider = $this->Request->User->findById($row['Request']['provider_id']);
$providerName = $provider['User']['firstname'] . ' ' .
$provider['User']['surname'];
$data = Hash::insert($requests, '{n}.Request.provider', $providerName);
endforeach;
$this->set('requests', $requests);
--
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 unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.