Skip to content

Commit

Permalink
WB-291: Update MachineCast set method to handle uninitialized machines
Browse files Browse the repository at this point in the history
Changed the set method in MachineCast to return null when the machine should not be initialized. This prevents errors when attempting to set values on uninitialized machines and ensures that only properly initialized machines are processed.
  • Loading branch information
deligoez committed Aug 12, 2024
1 parent 63f98aa commit c0b944f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Casts/MachineCast.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,12 @@ public function get(
* @param TSet|null $value
* @param array<mixed> $attributes
*/
public function set(Model $model, string $key, mixed $value, array $attributes): string
public function set(Model $model, string $key, mixed $value, array $attributes): ?string
{
if ($model->shouldInitializeMachine() === false) {
return null;
}

if (is_string($value)) {
return $value;
}
Expand Down

0 comments on commit c0b944f

Please sign in to comment.