Create helper functions

This commit is contained in:
Dennis Eichhorn 2017-02-14 23:28:12 +01:00
parent 8531c1422f
commit f0ccfc023a

View File

@ -449,7 +449,7 @@ class Builder extends BuilderAbstract
throw new \InvalidArgumentException('Unknown operator.');
}
$this->wheres[$key][] = [
$this->wheres[$this->getPublicColumnName($column)][] = [
'column' => $column,
'operator' => $operator[$i],
'value' => $values[$i],
@ -463,7 +463,7 @@ class Builder extends BuilderAbstract
throw new \InvalidArgumentException('Unknown operator.');
}
$this->wheres[null][] = ['column' => $columns, 'operator' => $operator, 'value' => $values,
$this->wheres[$this->getPublicColumnName($columns)][] = ['column' => $columns, 'operator' => $operator, 'value' => $values,
'boolean' => $boolean,];
} else {
throw new \InvalidArgumentException();
@ -472,6 +472,18 @@ class Builder extends BuilderAbstract
return $this;
}
public function getWhereByColumn($column)
{
return $this->wheres[$this->getPublicColumnName($column)] ?? null;
}
public function getTableOfSystem($expression, $systemIdentifier)
{
if(($pos = strpos($expression, $systemIdentifier . '.' . $systemIdentifier)) === false) {
return null;
}
}
/**
* Where and sub condition.
*
@ -1068,4 +1080,19 @@ class Builder extends BuilderAbstract
throw new \Exception();
}
public function getPublicColumnName($column) : string
{
if(is_string($column)) {
return $column;
} elseif($column instanceof Column) {
return $column->getPublicName();
} elseif($column instanceof \Closure) {
return $column();
} elseif($column instanceof \Serializable) {
return $column;
}
throw new \Exception();
}
}