From d00d55371c91f481b05b9f4c0d48b4bdce19a921 Mon Sep 17 00:00:00 2001 From: Dave Smith-Hayes Date: Mon, 11 Nov 2024 20:38:22 +0000 Subject: [PATCH] Change up the category entity. --- app/src/Domain/Entity/Category.php | 41 ++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 app/src/Domain/Entity/Category.php diff --git a/app/src/Domain/Entity/Category.php b/app/src/Domain/Entity/Category.php new file mode 100644 index 0000000..8a1d38f --- /dev/null +++ b/app/src/Domain/Entity/Category.php @@ -0,0 +1,41 @@ +name; + } + + /** + * @param array $props Key is each property of the entity + */ + public static function fromArray(array $props): self + { + $category = new self($props['name']); + + if ($props['id']) { + $category->setId($props['id']); + } + + if ($props['createdAt']) { + $category->setCreatedAt($props['createdAt']); + } + + if ($props['updatedAt']) { + $category->setUpdatedAt($props['updatedAt']); + } + + return $category; + } +}