Created
November 2, 2015 14:22
-
-
Save damianoporta/41fcb214cdb76bf46d70 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
/** | |
* Filtro per il recupero degli annunci che appartengono a determinati servizi | |
* | |
* @param Query $query | |
* @param array $options | |
* @return Query | |
*/ | |
public function findServices(Query $query, array $options) | |
{ | |
if (empty($options['matching'])) { | |
return $query->contain(['Services']); | |
} else { | |
return $query | |
->matching('Services', function(Query $q) use ($options) { | |
$operator = empty($options['exclude']) ? 'IN' : 'NOT IN'; | |
return $q->where(["Services.id $operator" => $options['Services.id']]); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment