required($body, 'body', 'Enter a comment.') ->maxLength($body, 'body', 2000, 'Comments are 2000 characters max.'); if ($validator->passes()) { // Same "bot gets an identical response" reasoning as the contact // form — see App/pages/contact/index.php. Only the insert is // skipped for spam. if (!$spamGuard->isSpam(Input::post())) { Comments::create($pagePath, $user['id'], $body); } return Response::redirect($pagePath); } $commentError = $validator->errors()['body'] ?? null; } return [ 'comments' => Comments::forPage($pagePath), 'currentUser' => $user, 'commentError' => $commentError, 'renderedAt' => $spamGuard->renderedAt(), 'csrfField' => Csrf::fieldName(), 'csrfToken' => Csrf::token(), ];