mirror of
https://github.com/flarum/framework.git
synced 2024-11-28 20:16:08 +08:00
fixed validation the date instead of integers
satisfying nitpick
This commit is contained in:
parent
d34d3f2b22
commit
5119dbca91
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
namespace Flarum\Suspend\Listener;
|
namespace Flarum\Suspend\Listener;
|
||||||
|
|
||||||
|
use Illuminate\Support\Arr;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Flarum\Core\Access\AssertPermissionTrait;
|
use Flarum\Core\Access\AssertPermissionTrait;
|
||||||
use Flarum\Event\UserWillBeSaved;
|
use Flarum\Event\UserWillBeSaved;
|
||||||
|
@ -50,16 +51,18 @@ class SaveSuspensionToDatabase
|
||||||
{
|
{
|
||||||
$attributes = array_get($event->data, 'attributes', []);
|
$attributes = array_get($event->data, 'attributes', []);
|
||||||
|
|
||||||
if (array_key_exists('suspendUntil', $attributes)) {
|
$suspendUntil = Arr::get($attributes, 'suspendUntil');
|
||||||
$this->validator->assertValid($attributes);
|
if ($suspendUntil) {
|
||||||
|
$suspendUntil = new Carbon($suspendUntil);
|
||||||
$suspendUntil = $attributes['suspendUntil'];
|
|
||||||
$user = $event->user;
|
|
||||||
$actor = $event->actor;
|
|
||||||
|
|
||||||
$this->assertCan($actor, 'suspend', $user);
|
|
||||||
|
|
||||||
$user->suspend_until = new Carbon($suspendUntil);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->validator->assertValid($attributes);
|
||||||
|
|
||||||
|
$user = $event->user;
|
||||||
|
$actor = $event->actor;
|
||||||
|
|
||||||
|
$this->assertCan($actor, 'suspend', $user);
|
||||||
|
|
||||||
|
$user->suspend_until = $suspendUntil;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,6 @@ class SuspendValidator extends AbstractValidator
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
protected $rules = [
|
protected $rules = [
|
||||||
'suspendUntil' => ['min:1', 'integer'],
|
'suspendUntil' => ['date'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user