BWSnippet

Cake PHP 3 - Order By a contain on parent

Cake PHP 3 - Order By a contain on parent

Relation contain ordered using an order by using cake php 3

	$user = $this->Users->get( $id , [
            'contain' => ['Events'=>[
            		'queryBuilder' => function ( $q ) {
						return $q->order(['date' => 'DESC']);
					},
            		'Photos'
            	]
            	,'Groups','Roles','UsersFriends'  ]
        ]);

Tags

Cake PHP 3 - Order By a contain on parent