This commit is contained in:
mcndave committed 2023-10-30 19:41:50 +00:00
commit f77c93ad20
19 files changed
+114 -57

No files matched your search

+10 -4
View File
@@ -65,7 +65,7 @@ class Repository
return $primaryKey ? $this->loadOneFromField($primaryKey, $value) : $this->wherePrimaryKey($value)->loadOne();
}
public function loadAll() : EntityCollection
public function loadAll () : EntityCollection
{
return $this->selectSqlQuery()->collectionFromQuery();
}
@@ -541,7 +541,7 @@ class Repository
return $this;
}
public function orderBy(string|\Stringable $field, ? string $direction = null) : self
public function orderBy(string|object $field, ? string $direction = null) : self
{
$this->queryBuilder->orderBy($field, $direction);
@@ -559,7 +559,13 @@ class Repository
public function orders(array $orderList) : self
{
foreach($orderList as $field => $direction) {
$this->orderBy($field, $direction);
if (is_numeric($field)) {
$this->orderBy($direction);
}
else {
# Associative array with direction
$this->orderBy($field, $direction);
}
}
return $this;
@@ -599,7 +605,7 @@ class Repository
$pkField = key($primaryKeyField);
return $this->where($primaryKeyField[$pkField]->name ?? $pkField, $value);
return $this->where($this->entityClass::field($primaryKeyField[$pkField]->name ?? $pkField), $value);
}
public function withJoin(string|array $fields, array $options = []) : self