From ee6655396e5b2aa74d6a947949bab78644f6f270 Mon Sep 17 00:00:00 2001 From: Jasper Vriends <4417659+jaspervriends@users.noreply.github.com> Date: Mon, 15 Mar 2021 00:44:45 +0100 Subject: [PATCH] Fixed issue #2 and #1 --- src/Badge/Command/CreateBadgeHandler.php | 5 ++++- src/BadgeCategory/Command/CreateBadgeCategoryHandler.php | 3 +++ src/UserBadge/Command/CreateUserBadgeHandler.php | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Badge/Command/CreateBadgeHandler.php b/src/Badge/Command/CreateBadgeHandler.php index 15e9421..bdcb389 100644 --- a/src/Badge/Command/CreateBadgeHandler.php +++ b/src/Badge/Command/CreateBadgeHandler.php @@ -52,12 +52,15 @@ public function handle(CreateBadge $command) Arr::get($command->data, "attributes.name", null), Arr::get($command->data, "attributes.image", null), Arr::get($command->data, "attributes.order", 0), - Arr::get($command->data, "attributes.dscription", null), + Arr::get($command->data, "attributes.description", null), Arr::get($command->data, "attributes.isVisible", true) ); + $badge->created_at = time(); + // Validate $this->validator->assertValid($badge->getDirty()); + // Save $badge->save(); diff --git a/src/BadgeCategory/Command/CreateBadgeCategoryHandler.php b/src/BadgeCategory/Command/CreateBadgeCategoryHandler.php index 09a7349..81f4e06 100644 --- a/src/BadgeCategory/Command/CreateBadgeCategoryHandler.php +++ b/src/BadgeCategory/Command/CreateBadgeCategoryHandler.php @@ -53,10 +53,13 @@ public function handle(CreateBadgeCategory $command) Arr::get($command->data, "attributes.description", null), Arr::get($command->data, "attributes.isEnabled", true), ); + + $badgeCategory->created_at = time(); // Validate $this->validator->assertValid($badgeCategory->getDirty()); + // Create category $badgeCategory->save(); diff --git a/src/UserBadge/Command/CreateUserBadgeHandler.php b/src/UserBadge/Command/CreateUserBadgeHandler.php index 4056f1a..9abe3de 100644 --- a/src/UserBadge/Command/CreateUserBadgeHandler.php +++ b/src/UserBadge/Command/CreateUserBadgeHandler.php @@ -61,6 +61,7 @@ public function handle(CreateUserBadge $command) $badgeUser = new UserBadge; $badgeUser->badge_id = $badge->id; $badgeUser->user_id = $user->id; + $badgeUser->assigned_at = time(); // Set earned reason if(Arr::has($command->data, "attributes.description")) {