Compare commits

...

3 Commits

Author SHA1 Message Date
as2252258 11a939e8a1 eee 2024-12-31 15:52:20 +08:00
as2252258 1666af9906 eee 2024-12-29 21:34:12 +08:00
as2252258 78f7faba55 eee 2024-12-29 21:10:58 +08:00
2 changed files with 1869 additions and 1867 deletions
+2 -2
View File
@@ -692,7 +692,7 @@ abstract class Model extends Component implements ModelInterface, ArrayAccess, \
public function __set(string $name, mixed $value): void
{
$prefix = 'set' . ucfirst($name);
if (method_exists($name, $prefix)) {
if (method_exists($this, $prefix)) {
$this->{$prefix}($value);
return;
}
@@ -766,7 +766,7 @@ abstract class Model extends Component implements ModelInterface, ArrayAccess, \
*/
protected function withRelate(string $name): mixed
{
$response = $this->$name();
$response = $this->{'get' . ucfirst($name)}();
if ($response instanceof \Database\Traits\Relation) {
$response = $response->get();
}
+11 -9
View File
@@ -793,20 +793,22 @@ abstract class QueryTrait extends Component implements ActiveQueryInterface, ISq
/**
* @param string $columns
* @param array|Closure $value
* @param array|Closure|Query $value
*
* @return $this
* @throws
* @throws Exception
*/
public function whereIn(string $columns, array|Closure $value): static
public function whereIn(string $columns, array|Closure|Query $value): static
{
if ($value instanceof Closure) {
$value = $this->makeClosureFunction($value);
}
if (count($value) < 1) {
$value = [-1];
}
if (is_array($value)) {
if (count($value) < 1) throw new Exception('Value must be an not empty array');
$this->where[] = $columns . ' IN (' . implode(',', $value) . ')';
} else if ($value instanceof Query) {
$this->where[] = $columns . ' IN (' . $value->build() . ')';
} else {
$this->where[] = $columns . ' IN (' . $this->makeClosureFunction($value) . ')';
}
return $this;
}