mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 12:42:48 +08:00
优化Request类的only和except方法 支持字符串传入
This commit is contained in:
@@ -406,14 +406,17 @@ class Request
|
||||
*/
|
||||
public function only($name)
|
||||
{
|
||||
$param = $this->param();
|
||||
if (is_string($name)) {
|
||||
return $this->param($name);
|
||||
} else {
|
||||
foreach ($name as $key) {
|
||||
$item[$key] = $this->param($name);
|
||||
}
|
||||
return $item;
|
||||
$name = explode(',', $name);
|
||||
}
|
||||
$item = [];
|
||||
foreach ($name as $key) {
|
||||
if (isset($param[$key])) {
|
||||
$item[$key] = $param[$key];
|
||||
}
|
||||
}
|
||||
return $item;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -426,14 +429,11 @@ class Request
|
||||
{
|
||||
$param = $this->param();
|
||||
if (is_string($name)) {
|
||||
if (isset($param[$name])) {
|
||||
unset($param[$name]);
|
||||
}
|
||||
} else {
|
||||
foreach ($name as $key) {
|
||||
if (isset($param[$key])) {
|
||||
unset($param[$key]);
|
||||
}
|
||||
$name = explode(',', $name);
|
||||
}
|
||||
foreach ($name as $key) {
|
||||
if (isset($param[$key])) {
|
||||
unset($param[$key]);
|
||||
}
|
||||
}
|
||||
return $param;
|
||||
|
||||
Reference in New Issue
Block a user