Я пишу конечную точку для POST-запроса, используя код ниже:
public function unifiedrequest(Request $request)
{
// prepare content
$password = $request->header('Password');
$username = $request->header('Username');
$msisdn=$request->msisdn;
$useresponse=$request->userresponse;
$useroption=$request->useroption;
$hash=$request->hash;
$hash_key="CIA152515276585";
$data=$msisdn.$useresponse.$useroption.$hash_key;
$hashed = hash('sha512',$data);
// return $hashed ;
if($username=="nbfd" && $password=="loka")
{
if($hashed==$hash)
{
//implemetation
$ref_id=self::gen_uuid();
$cus_name="greatB";
$total_amount=456;
$statuscode="00";
$statusMsg = "Successful";
$message="sdssa";
$data = $total_amount.$statuscode.$statusMsg.$message.$hash_key;
$hashed = hash('sha512',$data);
// $hash= $hashed;
$games = MBFA::where('game_code',$useresponse)->get();
User_Response::create([
'game_code' => $games->game_code,
'answer' => $useroption,
'msisdn' => $msisdn
]);
return response()->json([
'amount'=>$total_amount,
'statusCode'=>$statuscode,
'statusMessage'=>$statusMsg,
'message'=>$message,
'hash'=>$hashed
]);
}
}
Я ожидаю увидеть результат, но получил эту ошибку
Неопределенная переменная: game_code
$games = MBFA::where('game_code',$useresponse)->get();
User_Response::create([
'game_code' => $games->game_code,
'answer' => $useroption,
'msisdn' => $msisdn
]);
Пожалуйста, ознакомьтесь с приведенным ниже кодом для миграции в соответствии с просьбой.
CREATE TABLE `BBVA` (
`id` int(10) UNSIGNED NOT NULL,
`title` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`game_code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`game_answer1` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`answer_option_code1` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`answer_option_code2` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`answer_option_code3` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`answer_option_code4` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`answer_option_code5` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
`game_answer2` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`game_answer3` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`game_answer4` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`game_answer5` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`thank_you_message` text COLLATE utf8mb4_unicode_ci,
`header` text COLLATE utf8mb4_unicode_ci,
`footer` text COLLATE utf8mb4_unicode_ci
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Table structure for table `user_response`
--
CREATE TABLE `user_response` (
`id` int(10) UNSIGNED NOT NULL,
`msisdn` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`answer` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`answer_code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`Amount_charged` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`payment_ref` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`status` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
`game_code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
Я только что добавил подробности таблицы
Вот откуда исходит ошибка.Пожалуйста, что могло быть причиной и как мне ее устранить.
Заранее спасибо.