Skip to content
This repository was archived by the owner on Mar 12, 2024. It is now read-only.

Commit 214c04a

Browse files
committed
allow nullable array
1 parent e64e470 commit 214c04a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Traits/WithModelMapping.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ public function mapModelAttributes(?Model $model = null, mixed $rescue = null):
4242
/**
4343
* Map array data to class properties.
4444
*
45-
* @param array $data
45+
* @param array|null $data
4646
* @param mixed|null $rescue
4747
*
4848
* @return void
4949
*/
50-
public function arrayToProperties(array $data, mixed $rescue = null): void
50+
public function arrayToProperties(?array $data, mixed $rescue = null): void
5151
{
52-
collect($data)->each(function ($value, $key) use ($rescue) {
52+
collect($data ?? [])->each(function ($value, $key) use ($rescue) {
5353
if (property_exists($this, $key)) {
5454
rescue(
5555
fn () => $this->{$key} = $value,

0 commit comments

Comments
 (0)