Skip to content

Commit

Permalink
Add explicit request interaction
Browse files Browse the repository at this point in the history
  • Loading branch information
dillingham committed Dec 28, 2020
1 parent c7030ed commit 3dc0d82
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/AttachMany.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function __construct($name, $attribute = null, $resource = null)
$model::saved(function($model) use($attribute, $request) {

// fetch the submitted values
$values = json_decode($request->$attribute, true);
$values = json_decode(request()->input($attribute), true);

// remove `null` values that may be submitted
$filtered_values = array_filter($values);
Expand All @@ -69,7 +69,11 @@ public function __construct($name, $attribute = null, $resource = null)
}
});

unset($request->$attribute);
// prevent relationship json on parent resource:

$request->replace(
$request->except($attribute)
);
}
});
}
Expand Down

0 comments on commit 3dc0d82

Please sign in to comment.