Skip to content

Commit d26a9cd

Browse files
committed
let early return return the expected data
1 parent c115516 commit d26a9cd

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

Diff for: src/Relations/EmbedsOneOrMany.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -273,17 +273,17 @@ protected function toCollection(array $records = [])
273273
*
274274
* @return Model
275275
*/
276-
protected function toModel($attributes = [])
276+
protected function toModel(array $attributes = []): Model
277277
{
278-
if ($attributes === null) {
279-
return;
280-
}
281-
282278
$connection = $this->related->getConnection();
283279

280+
if (empty($attributes)) {
281+
return $this->related->newFromBuilder(connection: $connection?->getName());
282+
}
283+
284284
$model = $this->related->newFromBuilder(
285-
(array) $attributes,
286-
$connection ? $connection->getName() : null,
285+
$attributes,
286+
$connection?->getName(),
287287
);
288288

289289
$model->setParentRelation($this);

0 commit comments

Comments
 (0)