mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-02-12 23:08:41 +00:00
Create helper functions
This commit is contained in:
parent
8531c1422f
commit
f0ccfc023a
|
|
@ -449,7 +449,7 @@ class Builder extends BuilderAbstract
|
||||||
throw new \InvalidArgumentException('Unknown operator.');
|
throw new \InvalidArgumentException('Unknown operator.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->wheres[$key][] = [
|
$this->wheres[$this->getPublicColumnName($column)][] = [
|
||||||
'column' => $column,
|
'column' => $column,
|
||||||
'operator' => $operator[$i],
|
'operator' => $operator[$i],
|
||||||
'value' => $values[$i],
|
'value' => $values[$i],
|
||||||
|
|
@ -463,7 +463,7 @@ class Builder extends BuilderAbstract
|
||||||
throw new \InvalidArgumentException('Unknown operator.');
|
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,];
|
'boolean' => $boolean,];
|
||||||
} else {
|
} else {
|
||||||
throw new \InvalidArgumentException();
|
throw new \InvalidArgumentException();
|
||||||
|
|
@ -472,6 +472,18 @@ class Builder extends BuilderAbstract
|
||||||
return $this;
|
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.
|
* Where and sub condition.
|
||||||
*
|
*
|
||||||
|
|
@ -1068,4 +1080,19 @@ class Builder extends BuilderAbstract
|
||||||
|
|
||||||
throw new \Exception();
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user