Skip to content

Instantly share code, notes, and snippets.

@styks1987
Created January 19, 2016 20:38
Show Gist options
  • Save styks1987/ecf46edaf82e93d6630f to your computer and use it in GitHub Desktop.
Save styks1987/ecf46edaf82e93d6630f to your computer and use it in GitHub Desktop.
<?php
$following = $this->Strategies->Users
->matching(
'FollowingAgencies.Employees'
)
->where(['Users.id' => $this->Auth->user('id')])->toArray();
$following = Hash::extract($following, '{n}._matchingData.Employees.id');
$query = $this->Strategies->find('open')
->order(['Strategies.created DESC'])
->contain([
'Users.Agencies',
'Assisting' => function ($q){
return $q->order(['Assisting.last_name ASC', 'Assisting.first_name ASC']);
}])
->where(['Strategies.user_id IN' => $following]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment