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