Skip to content

Commit c004ffc

Browse files
daniserSergey Danilchenko
andauthored
[11.x] Fix determining pivot timestamp column name(s) when parent relation missing one or both of timestamps (#53103)
Co-authored-by: Sergey Danilchenko <s.danilchenko@ttbooking.ru>
1 parent cdffc89 commit c004ffc

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,14 @@ class BelongsToMany extends Relation
113113
/**
114114
* The custom pivot table column for the created_at timestamp.
115115
*
116-
* @var string
116+
* @var string|null
117117
*/
118118
protected $pivotCreatedAt;
119119

120120
/**
121121
* The custom pivot table column for the updated_at timestamp.
122122
*
123-
* @var string
123+
* @var string|null
124124
*/
125125
protected $pivotUpdatedAt;
126126

@@ -1478,7 +1478,7 @@ public function withTimestamps($createdAt = null, $updatedAt = null)
14781478
*/
14791479
public function createdAt()
14801480
{
1481-
return $this->pivotCreatedAt ?: $this->parent->getCreatedAtColumn();
1481+
return $this->pivotCreatedAt ?? $this->parent->getCreatedAtColumn() ?? Model::CREATED_AT;
14821482
}
14831483

14841484
/**
@@ -1488,7 +1488,7 @@ public function createdAt()
14881488
*/
14891489
public function updatedAt()
14901490
{
1491-
return $this->pivotUpdatedAt ?: $this->parent->getUpdatedAtColumn();
1491+
return $this->pivotUpdatedAt ?? $this->parent->getUpdatedAtColumn() ?? Model::UPDATED_AT;
14921492
}
14931493

14941494
/**

0 commit comments

Comments
 (0)