From 8b54f9bd683eef8697dbe7b221ffe18ec8f2e427 Mon Sep 17 00:00:00 2001 From: mamazu <14860264+mamazu@users.noreply.github.com> Date: Sun, 15 Oct 2023 13:46:25 +0200 Subject: [PATCH] Making the wishlist timestampable Adding `createdAt` and `updatedAt` fields to track if the wishlist is old and can be deleted. --- src/Entity/Wishlist.php | 5 +++++ src/Resources/config/doctrine/Wishlist.orm.xml | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/src/Entity/Wishlist.php b/src/Entity/Wishlist.php index 110d4467..c3119cf3 100644 --- a/src/Entity/Wishlist.php +++ b/src/Entity/Wishlist.php @@ -16,9 +16,12 @@ use Sylius\Component\Core\Model\ProductInterface; use Sylius\Component\Core\Model\ProductVariantInterface; use Sylius\Component\Core\Model\ShopUserInterface; +use Sylius\Component\Resource\Model\TimestampableTrait; class Wishlist implements WishlistInterface { + use TimestampableTrait; + protected ?int $id = null; protected ?string $name; @@ -38,6 +41,8 @@ public function __construct() $this->wishlistProducts = new ArrayCollection(); $this->token = new WishlistToken(); $this->id = null; + + $this->createdAt = new \DateTime(); } public function getId(): ?int diff --git a/src/Resources/config/doctrine/Wishlist.orm.xml b/src/Resources/config/doctrine/Wishlist.orm.xml index 646ec2fd..a1ea7f2a 100644 --- a/src/Resources/config/doctrine/Wishlist.orm.xml +++ b/src/Resources/config/doctrine/Wishlist.orm.xml @@ -30,6 +30,13 @@ + + + + + + +