Skip to content

Commit

Permalink
Merge branch 'kevdotbadger-patch-3' into 5.6
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Jan 9, 2018
2 parents d1208ec + aadd619 commit 75158f9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,12 @@ protected function addTimestampsToAttachment(array $record, $exists = false)
{
$fresh = $this->parent->freshTimestamp();

if ($this->using) {
$pivotModel = new $this->using;

$fresh = $fresh->format($pivotModel->getDateFormat());
}

if (! $exists && $this->hasPivotColumn($this->createdAt())) {
$record[$this->createdAt()] = $fresh;
}
Expand Down
2 changes: 2 additions & 0 deletions tests/Integration/Database/EloquentBelongsToManyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ public function custom_pivot_class()
$post->tagsWithCustomAccessor()->attach($tag->id);

$this->assertInstanceOf(CustomPivot::class, $post->tagsWithCustomPivot[0]->pivot);
$this->assertEquals('1507630210', $post->tagsWithCustomPivot[0]->pivot->getAttributes()['created_at']);

$this->assertEquals([
'post_id' => '1',
Expand Down Expand Up @@ -654,4 +655,5 @@ public function posts()

class CustomPivot extends Pivot
{
protected $dateFormat = 'U';
}

0 comments on commit 75158f9

Please sign in to comment.