Skip to content

Commit

Permalink
ignore static properties in serializes model
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Jan 23, 2018
1 parent 5f520f3 commit 8fad785
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/Illuminate/Queue/SerializesModels.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ public function __sleep()
));
}

return array_map(function ($p) {
return $p->getName();
}, $properties);
return array_filter(array_map(function ($p) {
return $p->isStatic() ? null : $p->getName();
}, $properties));
}

/**
Expand All @@ -37,6 +37,10 @@ public function __sleep()
public function __wakeup()
{
foreach ((new ReflectionClass($this))->getProperties() as $property) {
if ($property->isStatic()) {
continue;
}

$property->setValue($this, $this->getRestoredPropertyValue(
$this->getPropertyValue($property)
));
Expand Down

1 comment on commit 8fad785

@gocanto
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@taylorotwell Brother, what was the reason for this change? I am curios

Please sign in to comment.