Created
June 16, 2015 08:16
-
-
Save cholnhial/d741469e5b6599dc3483 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 stock($id = null) | |
{ | |
$fabric = $this->Fabrics->get($id, ['contain' => ['FabricColours']]); | |
if($this->request->is('post')) | |
{ | |
$list = $this->Fabrics->FabricColours->find('all')->where(['fabric_id' => $id])->toArray(); | |
$fabricColours = $this->Fabrics->patchEntities($list, $this->request->data('data')); | |
$data = $this->request->data['data']; | |
$countOf = count($fabricColours); | |
$this->set(array('data' => $data,'fabricColours' => $fabricColours,'list' => $list, 'countOf' => $countOf, '_serialize' => ['data', 'countOf', 'fabricColours', 'list'])); | |
return; | |
foreach($fabricColours as $fabricColour) | |
{ | |
$this->Fabrics->FabricColours->save($fabricColour); | |
} | |
} | |
$this->set('title', 'Colour stocks for ' . $fabric->name); | |
$this->set('_serialize', 'fabric'); | |
$this->set(compact('fabric')); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment