Interact with API result values as object properties in Laravel.

With the object method in the Laravel HTTP client, you can easily interact with API result values as object properties.

// https://api.adviceslip.com/advice response
// {
// "slip": {
// "id": 100,
// "advice": "Everybody makes mistakes."
// }
// }
 
$advice = Http::get('https://api.adviceslip.com/advice')->object();
 
$advice->slip->id; // 100
$advice->slip->advice; // Everybody makes mistakes.