Skip to content

[8.x] Clarify required timestamp columns for pivot tables #6427

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 2 commits into from
Sep 28, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions eloquent-relationships.md
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,8 @@ By default, only the model keys will be present on the `pivot` object. If your p
If you want your pivot table to have automatically maintained `created_at` and `updated_at` timestamps, use the `withTimestamps` method on the relationship definition:

return $this->belongsToMany('App\Models\Role')->withTimestamps();

> {note} When using timestamps on pivot tables, the table is required to have both `created_at` and `updated_at` timestamp columns.

#### Customizing The `pivot` Attribute Name

Expand Down