Created
December 18, 2015 12:02
-
-
Save McGaiser/ee9fa849e414b79cb7bc 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
public function editPrestige($id=null){ | |
$prestigeLog = $this->PrestigeLogs->get($id, | |
['contain'=>[ | |
'Members.Domains', | |
'PrestigeLogsItems'=> function ($q){ | |
return $q->where(['approved_id IS NULL']); | |
} | |
]]); | |
debug($prestigeLog); | |
debug($this->request->data()); | |
$prestigeLogsItems = $prestigeLog->prestige_logs_items; | |
if ($this->request->is(['post', 'put'])) { | |
//Update the object with request data. | |
$patched = $this->PrestigeLogs->PrestigeLogsItems->patchEntities($prestigeLogsItems, $this->request->data()); | |
$valid = true; | |
foreach($patched as $entity){ | |
$result = $this->PrestigeLogs->PrestigeLogsItems->save($entity); | |
if(!$result) $valid = false; | |
} | |
if ($valid) { | |
$this->Flash->success(__('The Prestige Log Items has been updated.')); | |
return $this->redirect(['action' => 'view', $id]); | |
} | |
$this->Flash->error(__('Unable to update the prestigeLog.')); | |
} | |
$affiliateId = $this->PrestigeLogs->PrestigeLogsItems->PrestigeItems->PrestigeCategories->Affiliates->getAffiliateIdByDomainId($this->request->session()->read('Auth.User.domain_id')); | |
$prestigeItems = $this->PrestigeLogs->PrestigeLogsItems->PrestigeItems->getPrestigeItemsList($affiliateId); | |
$domains = $this->PrestigeLogs->PrestigeLogsItems->Domains->find('list')->toArray(); | |
$venues = $this->PrestigeLogs->PrestigeLogsItems->Venues->find('list')->contain(['Games'])->group(['Games.id'])->toArray(); | |
$this->set(compact('prestigeLog', 'prestigeLogsItems', 'prestigeItems', 'domains', 'venues')); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment