Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[12.x] chore: return Collection from timestamps methods #55871

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

Merged
merged 1 commit into from
May 27, 2025

Conversation

calebdw
Copy link
Contributor

@calebdw calebdw commented May 27, 2025

Hello!

This returns a Collection from the timestamp methods that create more than one column---so that additional modifiers can be applied to the timestamps after they are created, such as ->useCurrent(), e.g.,

Schema::create('posts', function (Blueprint $table) {
    $this->timestampsTz()->each->useCurrent();
    // instead of 
    $this->timestampTz('created_at')->useCurrent();
    $this->timestampTz('updated_at')->useCurrent();
});

Some alternatives I considered:

  • directly add useCurrent / useCurrentWhenUpdating as parameters and apply the method to both columns
  • add an options parameter that gets passed down through the methods

Thanks!

This is so that additional modifiers can be applied to the timestamps
after they are created, such as `->useCurrent()`.
@taylorotwell taylorotwell merged commit e40622f into laravel:12.x May 27, 2025
57 of 61 checks passed
@calebdw calebdw deleted the calebdw/push-kzzzkpkvzsmz branch May 27, 2025 18:51
@shaedrich
Copy link
Contributor

shaedrich commented May 27, 2025

Some alternatives I considered:

  • directly add useCurrent / useCurrentWhenUpdating as parameters and apply the method to both columns
  • add an options parameter that gets passed down through the methods

Returning HigherOrderCollectionProxy would make for an intuitive API but would look weird typed because we don't do it this way anywhere else, right?

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.

3 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.