Skip to content
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

[8.x] Cast strings into Stringable #39400

Closed
wants to merge 1 commit into from
Closed

[8.x] Cast strings into Stringable #39400

wants to merge 1 commit into from

Conversation

louisgab
Copy link
Contributor

In the same way that dates like created_at casted into Carbon instances are convenient for easy manipulation:

$model->created_at->format('Y-m-d')

instead of

Date::createFromTimestamp($model->created_at)->format('Y-m-d')

I thought it would be cool to cast strings attribute into Stringable instances:

$model->name->title()

instead of

Str::of($model->name)->title()

What do you think about it?

@taylorotwell
Copy link
Member

Huge breaking change here. Probably would need to be a new cast like AsStringable::class

@louisgab louisgab deleted the feat/stringable-cast branch January 14, 2022 07:40
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