Skip to content

Instantly share code, notes, and snippets.

@discordier
Created September 23, 2016 14:13
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 discordier/683624414d493993d06f563a2f805b28 to your computer and use it in GitHub Desktop.
Save discordier/683624414d493993d06f563a2f805b28 to your computer and use it in GitHub Desktop.
Find MetaModels items using a `ConditionAnd` rule.
$attribute = $metaModel->getAttribute('price');
$filter = $metaModel->getEmptyFilter();
$andRule = new \MetaModels\Filter\Rules\Condition\ConditionAnd();
$andRule
->addRule(new \MetaModels\Filter\Rules\Comparing\GreaterThan($attribute, 10))
->addRule(new \MetaModels\Filter\Rules\Comparing\LessThan($attribute, 20));
$filter->addFilterRule($andRule);
$items = $metaModel->findByFilter($filter);
@zonky2
Copy link

zonky2 commented Oct 10, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment