Created
July 5, 2016 14:08
-
-
Save anonymous/02b46cc41578fd3cb7142231d921c8e8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if (!empty($this->request->data('applications.companies_ids'))) { | |
// Recupero gli ids delle aziende a cui l'agente si è candidato | |
$companiesIds = array_diff( | |
$this->request->data('applications.companies_ids'), | |
(new Collection($agent->applications))->extract('company_id')->toArray() | |
); | |
if (!empty($companiesIds)) { | |
$newCompanies = $this->Companies->find() | |
->contain(['Sectors']) | |
->where(['Companies.id IN' => $companiesIds]) | |
->all(); | |
foreach ($newCompanies as $company) { | |
$agent->applications[] = $this->Applications->newEntity([ | |
'company' => $company, | |
'agent_id' => $agent->get('id') | |
], ['associated' => ['Companies', 'Companies.Sectors']]); | |
} | |
} | |
exit(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment