Php Laravel控制器可以';t接收POST方法。是",;“区域”;有可能是保留字吗?
[ErrorException Undefined index:available_areas]发生。 不知何故,其他变量也可以。 我不确定为什么没有发送可用的\u区域。 POST数据被发送到RegisterUsers的register函数 register.blade.phpPhp Laravel控制器可以';t接收POST方法。是",;“区域”;有可能是保留字吗?,php,html,laravel,Php,Html,Laravel,[ErrorException Undefined index:available_areas]发生。 不知何故,其他变量也可以。 我不确定为什么没有发送可用的\u区域。 POST数据被发送到RegisterUsers的register函数 register.blade.php <div> <label for="areas">AVAILABLE AREAS</label> <input type="chec
<div>
<label for="areas">AVAILABLE AREAS</label>
<input type="checkbox" name="all_checked" > ALL<br/>
<p>
@foreach(config('ward') as $index => $name)
<input type="checkbox" name ="available_areas[]" value="{{ $index }}">{{$name}}
@endforeach
</p>
</div>
后数据样本
local.DEBUG: array (
'_token' => '2F5dbNfyyjf9mFtKCSVgAt5K2xXzNyRja3VVZB4X',
'name' => 'fgfgfgf',
'available_profiles' =>
array (
0 => '0',
1 => '1',
),
'profile' => '100',
'email' => 'sffftfdfdone@gmfail.com',
'adress' => '0',
'station' => 'fdfdfd',
'available_otto' =>
array (
0 => '3',
),
'password' => '12345678',
'password_confirmation' => '12345678',
)
使用请求类型提示
use Illuminate\Http\Request;
public function create(Request $request)
{
$areas = $request->available_areas;
//$areas = $request->input('available_areas'); //another way to get
}
要通过依赖项注入获取当前HTTP请求的实例,您应该在控制器方法上键入hintillighted\HTTP\request
类。传入请求实例将由服务容器自动注入:
use Illuminate\Http\Request;
public function create(Request $request)
{
$areas = $request->available_areas;
//$areas = $request->input('available_areas'); //another way to get
}