我如何循环 request()-> all() post (Laravel) 数据?

Van*_*ina 3 laravel eloquent

我试图循环访问 request:: all() 数组并返回值,但我只得到令牌。

这就是我目前正在尝试的,但它仅返回表单令牌

This is the JSON 

1   "microwaves"
2   "has enough energy to remove electrons from atoms"
3   "thyroid"
4   "stop immediately when switch is turned off"
5   "travel in a straight line"
6   "xrays and electrons"
7   "the radiation that hits the imaging plate"
8   "American limits and radiation allowances"
9   "genetic effects, those passed room parent to child"
10  "maximize distance from the source"
_token  "ABB88ZTnMAQ9DkuHb546aubz9ufK2SZQWxaKgm7w"
Run Code Online (Sandbox Code Playgroud)
public function store(){
  $data = request()->all();

  foreach ($data as $key) {
    return $key;
  }
``

Run Code Online (Sandbox Code Playgroud)

chu*_*erb 13

您忘记输入Request $request商店参数:

public function store(Request $request) {    
    $data = $request->all();

    foreach ($data as $key => $value) {
        return $value;
    }
}
Run Code Online (Sandbox Code Playgroud)


如果您尝试获取除 之外的整个请求_token,请使用以下命令:

public function store(Request $request) {    
    $data = $request->except('_token');

    foreach ($data as $key => $value) {
        return $value;
    }
}
Run Code Online (Sandbox Code Playgroud)