本文整理匯總了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]);
}