Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cesarockstar1985/7ecee9ac310553dfc36df5e9ffca9a3a to your computer and use it in GitHub Desktop.
Save cesarockstar1985/7ecee9ac310553dfc36df5e9ffca9a3a to your computer and use it in GitHub Desktop.
$this->addFilter('first_name', [
'className' => 'Custom',
'method' => fn(Query $query, $field, $value, $data, $options) =>
// debug($query->contain(['Males', 'Females'])->leftJoinWith('Profiles')),
$query
->contain(['Males', 'Females'])
->leftJoinWith('Profiles')
->where([
'OR' => [
// $query->newExpr()->like($this->Males->Profiles->first_name, '%' . $value . '%'),
$query->newExpr()->like($query->identifier('Females.first_name'), '%' . $value . '%'),
],
]),
]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment