private function _replaceSmartValues($modelData) { foreach ($modelData as $key => $value) { if (\CMS\Date::isDate($value)) { $modelData[$key] = \CMS\Date::toDbFormat($value); } } return $modelData; }
private static function _query($model, $conditions = array()) { $model = static::_parseModel($model); if ($model::$eagerLoadingRelationships) { $query = $model::with($model::$eagerLoadingRelationships); } else { $query = $model::where('id', '>', 0); } if (!$conditions) { return $query; } foreach ($conditions as $condition => $operator) { if (is_array($operator)) { foreach ($operator as $key => $value) { $comparison = $key == 'less_than' ? '<=' : '>='; if (\CMS\Date::isDate($value)) { $value = \CMS\Date::toDbFormat($value); } $query->where($condition, $comparison, $value); } continue; } if ($operator === 'AND') { die('To implement: and'); continue; } elseif ($operator === 'OR') { die('To implement: or'); continue; } if (\CMS\Date::isDate($operator)) { $operator = \CMS\Date::toDbFormat($operator); } $query->where($condition, $operator); } return $query; }