Skip to content

Commit

Permalink
Fill created datetime only if no date was provided beforehand
Browse files Browse the repository at this point in the history
  • Loading branch information
juniwalk authored Mar 11, 2023
1 parent 796713a commit 0bb5087
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/Traits/Timestamp.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,16 @@ public function getTimestamp(): DateTimeInterface
}


#[ORM\PreUpdate]
public function onUpdate(): void
#[ORM\PrePersist]
public function onCreated(): void
{
$this->modified = new DateTime;
$this->created ??= new DateTime;
}


#[ORM\PrePersist]
public function onPersist(): void
#[ORM\PreUpdate]
public function onModified(): void
{
$this->created = new DateTime;
$this->modified = new DateTime;
}
}

0 comments on commit 0bb5087

Please sign in to comment.