Dear All,
How do i apply condition at find('list') at Cakephp 3.0?
i have a Companies, Departments and Employees
Companies hasMany Department.
Companies hasMany Employees
Departments has Many Employees.
i want to add Employees from company & want to get departments list of that
company.
My Add method:
public function add($companyId = null){
if (!$companyId){
throw new NotFoundException(__('A Company is required'));
}
$this->loadModel('Companies');
$company = $this->Companies->get($companyId);
$employee = $this->Employees->newEntity($this->request->data);
if ($this->request->is('post')){
$employee->company_id = $company->id;
if ($this->Employees->save($employee)){
$this->Flash->success(__('The employee has been added
successfully'));
return $this->redirect(['action' => 'index']);
} else {
$this->Flash->error(__('Unable to add the employee, please
try again'));
}
}
$departments = $this->Companies->Departments->find('list'); *//
Here, Want to get only Departments lists of that company passed through
$companyId *
$this->set(compact('employee','departments'));
}
Could you please help suggesting me on this regard?
*Note: Sorry for my bad **English*
Thanks
Bayezid
--
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.