public static function has($relation, $operator = '>=', $count = 1, $id = '*')
{
$model = new static();
$info = $model->{$relation}()->getRelationInfo();
$table = $info['model']::getTable();
switch ($info['type']) {
case Relation::HAS_MANY:
return $model->db()->alias('a')->join($table . ' b', 'a.' . $info['localKey'] . '=b.' . $info['foreignKey'], $info['joinType'])->group('b.' . $info['foreignKey'])->having('count(' . $id . ')' . $operator . $count);
case Relation::HAS_MANY_THROUGH:
// TODO
// TODO
default:
return $model;
}
}