✏️ Describe the bug
When adding additional properties to a Data Object, they do not get wrapped by wrap().
↪️ To Reproduce
Provide us a pest test like this one which shows the problem:
it('cannot wrap additional properties', function () {
class UserData extends Data
{
public function __construct(
public string $name,
) {
}
}
dd(UserData::from(['name' => 'Ruben'])->additional(['role' => 'admin'])->wrap('data'));
});
Assertions aren't required, a simple dump or dd statement of what's going wrong is good enough 😄
✏️ Describe the bug When adding additional properties to a Data Object, they do not get wrapped by wrap().
↪️ To Reproduce Provide us a pest test like this one which shows the problem:
Assertions aren't required, a simple dump or dd statement of what's going wrong is good enough 😄
✅ Expected behavior I'm expecting this to produce
but instead, I get [ "data" => [ "name" => "Ruben", ], "rank" => "admin", ]
A similar thing happens when I add a with() method to the object.
🖥️ Versions
Laravel: v10.48.22 Laravel Data: 4.11.0 PHP: 8.2.20