Skip to content

[12.x] Add uri() method to InteractsWithData trait #56106

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from

Conversation

adevade
Copy link
Contributor

@adevade adevade commented Jun 23, 2025

Description

This PR adds a uri() method to the Illuminate\Support\Traits\InteractsWithData trait that creates a new Illuminate\Support\Uri instance.

Usage with Fluent

Fluent::make([
    'website' => 'https://laravel.com', 
])->uri('website');

// Result: Illuminate\Support\Uri {
//   #uri: League\Uri\Uri {
//     -scheme: "https"
//     -user: null
//     -pass: null
//     -userInfo: null
//     -host: "laravel.com"
//     -port: null
//     -authority: "laravel.com"
//     -path: ""
//     -query: null
//     -fragment: null
//     -uri: "https://laravel.com"
//   }
// }

@adevade
Copy link
Contributor Author

adevade commented Jun 23, 2025

I just realized that maybe this fits better directly on the Fluent class, to not be confused with the uri() method on the Request class?

@taylorotwell
Copy link
Member

Correct, we may not be able to add it to this trait.

@taylorotwell taylorotwell marked this pull request as draft June 23, 2025 22:39
@adevade adevade marked this pull request as ready for review June 24, 2025 08:18
@adevade
Copy link
Contributor Author

adevade commented Jun 24, 2025

I have now moved the method from the InteractsWithData trait, over to the Fluent class.

@taylorotwell
Copy link
Member

Looking at code we could actually already do $fluent->string('foo')->toUri()

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