本文整理汇总了PHP中GrahamCampbell\Binput\Facades\Binput::map方法的典型用法代码示例。如果您正苦于以下问题:PHP Binput::map方法的具体用法?PHP Binput::map怎么用?PHP Binput::map使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GrahamCampbell\Binput\Facades\Binput
的用法示例。
在下文中一共展示了Binput::map方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
/**
* Update an existing comment.
*
* @param int $postId
* @param int $id
*
* @throws \Symfony\Component\HttpKernel\Exception\BadRequestHttpException
* @throws \Symfony\Component\HttpKernel\Exception\ConflictHttpException
*
* @return \Illuminate\Http\JsonResponse
*/
public function update($postId, $id)
{
$input = Binput::map(['edit_body' => 'body']);
if (CommentRepository::validate($input, array_keys($input))->fails()) {
throw new BadRequestHttpException('Your comment was empty.');
}
$comment = CommentRepository::find($id);
$this->checkComment($comment);
$version = Binput::get('version');
if (empty($version)) {
throw new BadRequestHttpException('No version data was supplied.');
}
if ($version != $comment->version && $version) {
throw new ConflictHttpException('The comment was modified by someone else.');
}
$version++;
$comment->update(array_merge($input, ['version' => $version]));
return Response::json(['success' => true, 'msg' => 'Comment updated successfully.', 'comment_text' => nl2br(e($comment->body)), 'comment_id' => $id, 'comment_ver' => $version]);
}