我正在使用HTMLPurifier for Laravel 5包来清理我的输入字段。目前我的store()
方法是这样的:
public function store(Request $request)
{
// Some business logic goes here
$post = Post::create($request->all());
// More business logic
}
和我的$request
变量包含以下内容:
{
"_token": "zbyUnJuAbSliem40B6xjWJfGOayoFlRSVIvrDlDM",
"title": "Test Title",
"slug": "test-title",
"category_id": "1",
"tags": [
"2"
],
"body": "<p>Test body.</p>"
}
如何仅在Purifier::clean()
变量上使用$request
方法来纯化$request->body
元素?
如果我使用Purifier::clean($request->all())
,则会将<p>
标记添加到$request
对象的所有元素,而不是body
这样的元素:
{
"_token": "<p>zbyUnJuAbSliem40B6xjWJfGOayoFlRSVIvrDlDM</p>",
"title": "<p>Test Title</p>",
"slug": "<p>test-title</p>",
"category_id": "<p>1</p>",
"tags": [
"<p>2</p>"
],
"body": "<p>Test body.</p>"
}
答案 0 :(得分:0)
你能试试这个:
Nullable<double> someVar = new Nullable<double>();
someVar.Value = null;