Skip to content

Version v0.8.1

Choose a tag to compare

@Sammyjo20 Sammyjo20 released this 28 Feb 21:19
f2927aa

This release introduces a first-party way to cast directly to a DTO of your choice.

Firstly, add the "CastsToDto" trait to your request. After that, you need to add the "castToDto" method on the request. This should return your DTO with the data populated inside of it.

public function castToDto(SaloonResponse $response): object
{
    return User::fromSaloon($response);
}

After your request has been sent, you can use the dto method on the response to retrieve your DTO.

$response = UserRequest::make()->send();
$dto = $response->dto(); // Data\User

What's Changed

Full Changelog: v0.8.0...v0.8.1