Skip to content

Conversation

@devajmeireles
Copy link
Contributor

Relates to #56094


This PR aims to ensure the Uri class is converted to JSON, fixing the issue: #56094

Before this PR, an API that uses the url attribute as using the new AsUri cast, will respond like this:

Route::get('/testing', function () {
    return User::first()->only('id', 'url');
});

Will result in it:

{
    "id": 1,
    "url": {}
}

After this PR, the value will be correctly converted to the expected Uri output:

{
    "id": 1,
    "url": "https://sanford.biz/..."
}

@devajmeireles
Copy link
Contributor Author

I don't think the test failure is related exactly to the changes in this PR.

@taylorotwell taylorotwell merged commit 767a42c into laravel:12.x Jun 22, 2025
60 checks passed
mohammad-fouladgar pushed a commit to mohammad-fouladgar/framework that referenced this pull request Jul 22, 2025
* Added JsonSerializable interface to Uri class and implemented jsonSerialize function

* Updated return type of jsonSerialize function in Uri.php

* Update Uri.php

---------

Co-authored-by: Taylor Otwell <taylor@laravel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants