Skip to content

Commit 116f61e

Browse files
committed
Fix select behaviour
1 parent d51ca5e commit 116f61e

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/Query/Model/Builder.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -569,13 +569,20 @@ public function get(array|string $selects = ['*']): Collection
569569
/**
570570
* Select the given attributes to retrieve.
571571
*/
572-
public function select(array|string $selects): static
572+
public function select(array|string $selects = ['*']): static
573573
{
574+
$selects = is_array($selects) ? $selects : func_get_args();
575+
576+
// Default to all attributes if empty.
577+
if (empty($selects)) {
578+
$selects = ['*'];
579+
}
580+
574581
// If selects are being overridden, then we need to ensure
575582
// the GUID key is always selected so that it may be
576583
// returned in the results for model hydration.
577584
$selects = array_values(array_unique(
578-
array_merge([$this->model->getGuidKey()], (array) $selects)
585+
array_merge([$this->model->getGuidKey()], $selects)
579586
));
580587

581588
$this->query->select($selects);
@@ -588,6 +595,8 @@ public function select(array|string $selects): static
588595
*/
589596
public function addSelect(array|string $select): static
590597
{
598+
$select = is_array($select) ? $select : func_get_args();
599+
591600
$this->query->addSelect($select);
592601

593602
return $this;

0 commit comments

Comments
 (0)