Run the find on the associated model.
I'm assuming that your statuses table has a 'name' column. Adjust as necessary.
In the Employee model:
public function fetchByStatus($status)
{
return $this->Status->find(
'all',
array(
'conditions' => array'Status.name' => $status),
'recursive' => 0 // or 1
)
);
}
or:
public function fetchByStatus($status)
{
return $this->Status->find(
'all',
array(
'conditions' => array'Status.name' => $status),
'contain' => array(
'Employee'
)
)
);
}
In the EmployeesController:
$data = $this->Employee->fetchByStatus($status);
Note that if you might in the future include a status that is not
URL-friendly, (eg. "A Multi-word Status" it would be best to create a
slug column instead of passing the name to the controller.
On Sat, Feb 16, 2013 at 7:19 AM, Victor Musvibe <jaahvicky@gmail.com> wrote:
> I have an employees table with status that is active, new and resigned. In
> my drop down menu for the application i have all 3 different statuses that
> is active, new and resigned,now i wanna link to each different status, that
> is when i click on active it only shows me the active users in the employee
> table.
>
> Please not status table is linked to the employees table.
>
> Thank you in advance.
>
> --
> 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 cake-php+unsubscribe@googlegroups.com.
> To post to this group, send email to cake-php@googlegroups.com.
> Visit this group at http://groups.google.com/group/cake-php?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
--
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 cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
Saturday, February 16, 2013
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment