Skip to content

Instantly share code, notes, and snippets.

@cpierce
Created June 3, 2016 05:31
Show Gist options
  • Save cpierce/932722aee20b43b6a759152434ed498f to your computer and use it in GitHub Desktop.
Save cpierce/932722aee20b43b6a759152434ed498f to your computer and use it in GitHub Desktop.
public function add()
{
if ( ! $this->request->data) {
$this->response->statusCode('400');
} else {
$data['feeds']['_ids'] = $this->request->data['feeds'];
$calendars = TableRegistry::get('Calendars');
$calendar = $calendars->get($this->request->data['id'], [
'associated' => [
'Feeds',
],
]);
debug($calendar);
$calendar = $calendars->patchEntity($calendar, $data);
debug($calendar);
if ($calendars->save($calendar, ['associated' => ['Feeds']])) {
echo 'yes';
} else {
echo 'no';
}
debug($calendar);
die();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment