Skip to content

Commit 09ffd7f

Browse files
authored
Fix getWith should always return array.
Not sure about the fist check, I think we could check against `null` instead, but this way the previous behavior is preserved.
1 parent b964ae2 commit 09ffd7f

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/Traits/ModelTrait.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,18 @@ public function without($tables)
8282
*/
8383
protected function getWith(): array
8484
{
85-
return empty($this->with) ? [] : $this->with;
85+
// Ensure $this->with is set at all
86+
if(empty($this->with)){
87+
$this->with = [];
88+
}
89+
90+
// Force a single table name into an array
91+
if (!is_array($this->with))
92+
{
93+
$this->with = [$this->with];
94+
}
95+
96+
return $this->with;
8697
}
8798

8899
/**

0 commit comments

Comments
 (0)