We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c115516 commit d26a9cdCopy full SHA for d26a9cd
src/Relations/EmbedsOneOrMany.php
@@ -273,17 +273,17 @@ protected function toCollection(array $records = [])
273
*
274
* @return Model
275
*/
276
- protected function toModel($attributes = [])
+ protected function toModel(array $attributes = []): Model
277
{
278
- if ($attributes === null) {
279
- return;
280
- }
281
-
282
$connection = $this->related->getConnection();
283
+ if (empty($attributes)) {
+ return $this->related->newFromBuilder(connection: $connection?->getName());
+ }
+
284
$model = $this->related->newFromBuilder(
285
- (array) $attributes,
286
- $connection ? $connection->getName() : null,
+ $attributes,
+ $connection?->getName(),
287
);
288
289
$model->setParentRelation($this);
0 commit comments