Php 我得到了错误FatalThrowableError类型错误:传递给Illumb\Http\Request::merge()的参数1必须是数组的类型,给定null
我想用Google Authenticator做一个双因素认证的登记表。当我尝试注册一个新的用户帐户,扫描生成的二维码,然后按下“完全注册”按钮时,我刚刚得到一个错误 FatalThroTableError类型错误:参数1传递给 Illumb\Http\Request::merge的类型必须为array,null 给予,召唤 C:\xampp\htdocs\repository\app\Http\Controllers\Auth\RegisterController.php 在线113 这是我的注册控制器Php 我得到了错误FatalThrowableError类型错误:传递给Illumb\Http\Request::merge()的参数1必须是数组的类型,给定null,php,laravel,Php,Laravel,我想用Google Authenticator做一个双因素认证的登记表。当我尝试注册一个新的用户帐户,扫描生成的二维码,然后按下“完全注册”按钮时,我刚刚得到一个错误 FatalThroTableError类型错误:参数1传递给 Illumb\Http\Request::merge的类型必须为array,null 给予,召唤 C:\xampp\htdocs\repository\app\Http\Controllers\Auth\RegisterController.php 在线113 这是我的
public function register(Request $request)
{
//first we will validate the incoming request
$this->validator($request->all())->validate();
// Initialise the 2FA class
$google2fa = app('pragmarx.google2fa');
// store registration data in an array
$registration_data = $request->all();
// Create new secret key to the registration data
$registration_data["google2fa_secret"] = $google2fa->generateSecretKey();
// store registration data to the user session for new request
$request->session()->flash('registration_data', $registration_data);
// Create the QR image.
$QR_Image = $google2fa->getQRCodeInline(
config('app.name'),
$registration_data['email'],
$registration_data['username'],
$registration_data['google2fa_secret']
);
// Send the QR barcode image to our view
return view('google2fa.register', ['QR_Image' => $QR_Image, 'secret' => $registration_data['google2fa_secret']]);
}
public function completeRegistration(Request $request)
{
// add the session data back to the request input
$request->merge(session('registration_data')); <- I got error because of this line (in line 113)
// Call the default laravel authentication
<br>return $this->registration($request);
}
这是路线地址
路由::获取“/完成注册”,“身份验证”\RegisterController@completeRegistration';
我已经在上面的寄存器控制器中输入了方法completeRegistration使用if条件检查注册数据是否为空
if (session('registration_data') != '' && session('registration_data') != null)
{
$request->merge(session('registration_data'));
}
你需要像这样使用
$request->merge(['registration_date'=>session('registration_data')]);
错误很明显:会话'registration_data'为空,它必须是一个数组。顺便说一句,用1个参数调用array_merge函数是没有用的