diff --git a/extensions/suspend/src/Listener/SaveSuspensionToDatabase.php b/extensions/suspend/src/Listener/SaveSuspensionToDatabase.php index 88e1f12e5..35e31f9f1 100755 --- a/extensions/suspend/src/Listener/SaveSuspensionToDatabase.php +++ b/extensions/suspend/src/Listener/SaveSuspensionToDatabase.php @@ -10,6 +10,7 @@ namespace Flarum\Suspend\Listener; +use Illuminate\Support\Arr; use Carbon\Carbon; use Flarum\Core\Access\AssertPermissionTrait; use Flarum\Event\UserWillBeSaved; @@ -50,16 +51,18 @@ class SaveSuspensionToDatabase { $attributes = array_get($event->data, 'attributes', []); - if (array_key_exists('suspendUntil', $attributes)) { - $this->validator->assertValid($attributes); - - $suspendUntil = $attributes['suspendUntil']; - $user = $event->user; - $actor = $event->actor; - - $this->assertCan($actor, 'suspend', $user); - - $user->suspend_until = new Carbon($suspendUntil); + $suspendUntil = Arr::get($attributes, 'suspendUntil'); + if ($suspendUntil) { + $suspendUntil = new Carbon($suspendUntil); } + + $this->validator->assertValid($attributes); + + $user = $event->user; + $actor = $event->actor; + + $this->assertCan($actor, 'suspend', $user); + + $user->suspend_until = $suspendUntil; } } diff --git a/extensions/suspend/src/SuspendValidator.php b/extensions/suspend/src/SuspendValidator.php index 7ec3a4e40..121bf6208 100644 --- a/extensions/suspend/src/SuspendValidator.php +++ b/extensions/suspend/src/SuspendValidator.php @@ -18,6 +18,6 @@ class SuspendValidator extends AbstractValidator * {@inheritdoc} */ protected $rules = [ - 'suspendUntil' => ['min:1', 'integer'], + 'suspendUntil' => ['date'], ]; }