@@ -241,7 +241,7 @@ look like::
241241 'tags' => [
242242 ['name' => 'CakePHP'],
243243 ['name' => 'Internet'],
244- ]
244+ ],
245245 ];
246246
247247The above will create 2 new tags. If you want to link an article with existing
@@ -252,8 +252,8 @@ tags you can use a list of ids. Your request data should look like::
252252 'body' => 'The text',
253253 'user_id' => 1,
254254 'tags' => [
255- '_ids' => [1, 2, 3, 4]
256- ]
255+ '_ids' => [1, 2, 3, 4],
256+ ],
257257 ];
258258
259259If you need to link against some existing belongsToMany records, and create new
@@ -267,8 +267,8 @@ ones at the same time you can use an expanded format::
267267 ['name' => 'A new tag'],
268268 ['name' => 'Another new tag'],
269269 ['id' => 5],
270- ['id' => 21]
271- ]
270+ ['id' => 21],
271+ ],
272272 ];
273273
274274When the above data is converted into entities, you will have 4 tags. The first
@@ -299,7 +299,7 @@ association populated. You can then use request data similar to::
299299 ['id' => 1, 'comment' => 'Update the first comment'],
300300 ['id' => 2, 'comment' => 'Update the second comment'],
301301 ['comment' => 'Create a new comment'],
302- ]
302+ ],
303303 ];
304304
305305If you are saving hasMany associations and want to link existing records to a
@@ -310,8 +310,8 @@ new parent record you can use the ``_ids`` format::
310310 'body' => 'The text',
311311 'user_id' => 1,
312312 'comments' => [
313- '_ids' => [1, 2, 3, 4]
314- ]
313+ '_ids' => [1, 2, 3, 4],
314+ ],
315315 ];
316316
317317When converting hasMany data, you can disable the new entity creation, by using
@@ -334,11 +334,11 @@ In this situation, the request data for multiple articles should look like::
334334 $data = [
335335 [
336336 'title' => 'First post',
337- 'published' => 1
337+ 'published' => 1,
338338 ],
339339 [
340340 'title' => 'Second post',
341- 'published' => 1
341+ 'published' => 1,
342342 ],
343343 ];
344344
@@ -378,11 +378,11 @@ keep ids of associated entities::
378378 'Tags', 'Comments' => [
379379 'associated' => [
380380 'Users' => [
381- 'accessibleFields' => ['id' => true]
382- ]
383- ]
384- ]
385- ]
381+ 'accessibleFields' => ['id' => true],
382+ ],
383+ ],
384+ ],
385+ ],
386386 ]);
387387
388388The above will keep the association unchanged between Comments and Users for the
@@ -446,7 +446,7 @@ merge deeper to deeper levels, you can use the third parameter of the method::
446446 $associated = ['Tags', 'Comments.Users'];
447447 $article = $articles->get(1, ['contain' => $associated]);
448448 $articles->patchEntity($article, $this->request->getData(), [
449- 'associated' => $associated
449+ 'associated' => $associated,
450450 ]);
451451 $articles->save($article);
452452
@@ -459,8 +459,8 @@ For example give some request data like the following::
459459 $data = [
460460 'title' => 'My title',
461461 'user' => [
462- 'username' => 'mark'
463- ]
462+ 'username' => 'mark',
463+ ],
464464 ];
465465
466466Trying to patch an entity without an entity in the user property will create
@@ -504,7 +504,7 @@ For example, consider the following case::
504504 'comments' => [
505505 ['body' => 'First comment', 'id' => 1],
506506 ['body' => 'Second comment', 'id' => 2],
507- ]
507+ ],
508508 ];
509509 $entity = $articles->newEntity($data);
510510 $articles->save($entity);
@@ -513,7 +513,7 @@ For example, consider the following case::
513513 'comments' => [
514514 ['body' => 'Changed comment', 'id' => 1],
515515 ['body' => 'A new comment'],
516- ]
516+ ],
517517 ];
518518 $articles->patchEntity($entity, $newData);
519519 $articles->save($entity);
@@ -527,7 +527,7 @@ following result::
527527 'comments' => [
528528 ['body' => 'Changed comment', 'id' => 1],
529529 ['body' => 'A new comment'],
530- ]
530+ ],
531531 ];
532532
533533As you can see, the comment with id 2 is no longer there, as it could not be
@@ -548,7 +548,7 @@ delete for those not in the list::
548548 $present = (new Collection($entity->comments))->extract('id')->filter()->toList();
549549 $comments->deleteAll([
550550 'article_id' => $article->id,
551- 'id NOT IN' => $present
551+ 'id NOT IN' => $present,
552552 ]);
553553
554554As you can see, this also helps creating solutions where an association needs to
@@ -657,7 +657,7 @@ validation logic that you cannot easily express through Validator methods::
657657 ) {
658658 // Don't accept people who have a name starting with J on the 20th
659659 // of each month.
660- if (substr ($entity->name, 1) == 'J' && date('d') === 20) {
660+ if (mb_substr ($entity->name, 1) = == 'J' && date('d') === 20) {
661661 $entity->setError('name', 'No J people today sorry.');
662662 }
663663 }
0 commit comments