/** * Get additional content data selected * * @param $result = Query result */ public static function post_find($result) { if ($result !== null) { if (is_array($result)) { foreach ($result as $item) { // It will first check if we already have result in temporary result, // and only execute query if we dont. That way we dont have duplicate queries // Get attribute options $item->get_options = static::lazy_load(function () use($item) { return Model_Attribute_Option::find(array('where' => array('attribute_id' => $item->id), 'order_by' => array('sort' => 'asc')), 'id'); }, $item->id, 'options'); } } } // return the result return $result; }