From 8ae915e3dabf2330329c1c4528e0be8760d00478 Mon Sep 17 00:00:00 2001 From: will Date: Fri, 9 Oct 2020 10:38:46 +0000 Subject: [PATCH] Enable setting of unsubscribed_at through API --- src/Http/Requests/Api/SubscriberStoreRequest.php | 3 ++- src/Http/Requests/Api/SubscriberUpdateRequest.php | 1 + src/Http/Resources/Subscriber.php | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Http/Requests/Api/SubscriberStoreRequest.php b/src/Http/Requests/Api/SubscriberStoreRequest.php index 6f2310c3..6cdc630b 100644 --- a/src/Http/Requests/Api/SubscriberStoreRequest.php +++ b/src/Http/Requests/Api/SubscriberStoreRequest.php @@ -14,7 +14,8 @@ public function rules(): array 'first_name' => ['nullable'], 'last_name' => ['nullable'], 'email' => ['required', 'email'], - 'segments' => ['array', 'nullable'] + 'segments' => ['array', 'nullable'], + 'unsubscribed_at' => ['nullable', 'date'], ]; } } diff --git a/src/Http/Requests/Api/SubscriberUpdateRequest.php b/src/Http/Requests/Api/SubscriberUpdateRequest.php index 278a759d..ae652aa9 100644 --- a/src/Http/Requests/Api/SubscriberUpdateRequest.php +++ b/src/Http/Requests/Api/SubscriberUpdateRequest.php @@ -15,6 +15,7 @@ public function rules(): array 'last_name' => ['nullable'], 'email' => ['required', 'email'], 'segments' => ['nullable', 'array'], + 'unsubscribed_at' => ['nullable', 'date'], ]; } } diff --git a/src/Http/Resources/Subscriber.php b/src/Http/Resources/Subscriber.php index afe6667c..90d8d75f 100644 --- a/src/Http/Resources/Subscriber.php +++ b/src/Http/Resources/Subscriber.php @@ -21,6 +21,7 @@ public function toArray($request) 'last_name' => $this->last_name, 'email' => $this->email, 'segments' => SegmentResource::collection($this->whenLoaded('segments')), + 'unsubscribed_at' => $this->unsubscribed_at ? $this->unsubscribed_at->toDateTimeString() : null, 'created_at' => $this->created_at->toDateTimeString(), 'updated_at' => $this->updated_at->toDateTimeString() ];