Skip to content

Instantly share code, notes, and snippets.

@anthonybudd
Last active February 13, 2017 10:00
Show Gist options
  • Select an option

  • Save anthonybudd/3e36fc17204f9468d3d14ada7351ec87 to your computer and use it in GitHub Desktop.

Select an option

Save anthonybudd/3e36fc17204f9468d3d14ada7351ec87 to your computer and use it in GitHub Desktop.
<?php
Class Product extends WP_Model
{
...
public function _finderHeavy($agrs){
...
}
public function _postFinderHeavy($results, $args){
return array_map(function($model){
if($model->color == 'blue'){
return $model;
}
}, $results);
}
}
$heavyProducts = Product::finder('heavy', ['heavierThan' => 250]); // [Product, Product, Product];
echo $heavyProducts[0]->color; // 'blue'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment