如果$ request对象和我需要检查某些值是否在$ request
Request {#43 ▼
#json: null
#convertedFiles: null
#userResolver: Closure {#170 ▶}
#routeResolver: Closure {#172 ▶}
+attributes: ParameterBag {#45 ▶}
+request: ParameterBag {#44 ▼
#parameters: array:18 [▼
"_token" => "sT4yCby4ieh3rHAK0MBcMIcYkGMDzjs0Jf1co4WS"
"is_demand" => "1"
"title" => null
"main_category" => "C01"
"secondary_category" => "C0201"
"main_category_2" => "C01"
"secondary_category_2" => "C0201"
"status" => "granted"
"interest" => "code1"
"keywords" => null
"keywords_secondary" => null
"challenge" => null
"requirement" => null
"summary" => null
"dateStart" => "1970-01-01"
"dateEnd" => "2017-11-07"
"trlMin" => null
"trlMax" => null
]
}
尝试
if ( ! property_exists($this->request, 'is_demand')) {
throw new \Exception('"is_demand" is undefined');
}
但是获得异常,虽然定义了is_demand并且具有值
我的错误或缺乏理解是什么?
答案 0 :(得分:1)
= 1
GROUP BY md
)t2
ON t2.md = t1.md
LEFT JOIN
(
SELECT DATE_FORMAT(date_lm, "%b") AS month, COUNT(*) AS total ,DATE_FORMAT(date_lm, "%Y-%m") AS md
FROM tbl_users
WHERE date_lm <= NOW() AND date_lm >= Date_add(Now(),INTERVAL - 11 MONTH) AND status = 'submitted'
GROUP BY md
)t3
ON t3.md = t1.md
GROUP BY t1.md
ORDER BY t1.md
是ParameterBag
。它不仅没有$this->request
属性,而且你甚至不关心它的属性,而是它所包含的参数的值。
使用has()
课程提供的ParameterBag
方法找出您需要的内容:
is_demand