重定向到刀片中未显示会话闪存数据



我对成功有问题->结果重定向成功后我看不到结果

主页.blade.php

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title></title>
</head>
<body>
<center>
<form method="POST" action="{{ route ('imei') }}" style="margin-top:5%">
@csrf
<p><input type="text" style="padding: 15px 10px 10px; font-family: 'Source Sans Pro',arial,sans-serif; border: 1px solid #cecece; color: black;box-sizing: border-box; width: 50%; max-width: 500px;" name="imei" autocomplete="off" maxlength="50" placeholder="Write here IMEI or SN"></p>
<select name="service" id="service" style="padding: 15px 10px 10px; font-family: 'Source Sans Pro',arial,sans-serif; border: 1px solid #cecece; color: black;box-sizing: border-box; width: 50%; max-width: 500px;">
<option value="0" selected="selected">PLEASE CHOOSE CHECKER</option>
<optgroup label="iPHONE SERVICES">
<option value="0.01">1.10 - APPLE SOLD BY & COVERAGE &#x26A1;</option>
</optgroup>
</select>
<br /><br />
<button onClick="this.form.submit(); this.disabled=true; this.value='Please Wait'; " type="submit" style="background-color: #2ABCA7; padding: 12px 45px; -ms-border-radius: 5px; -o-border-radius: 5px; border-radius: 5px; border: 1px solid #2ABCA7;-webkit-transition: .5s; transition: .5s; display: inline-block; cursor: pointer; width: 20%; max-width: 200px; color: #fff;">Submit</button>
</form>
</center>
<script src="//cdn.jsdelivr.net/npm/sweetalert2@11"></script>
@if (Session::has('success'))
<script type="text/javascript">
Swal.fire({
position: 'center',
icon: 'success',
title: "{!! Session::get('success') !!}",
showConfirmButton: false,
timer: 2500
})
</script>
@elseif (Session::has('error'))
<script type="text/javascript">
Swal.fire({
position: 'center',
icon: 'error',
title: "{!! Session::get('error') !!}",
showConfirmButton: false,
timer: 2500
})
</script>
@endif
</body>
</html>

控制器

public function imeiSubmit()
{
$format = "html"; // Display result in JSON or HTML format
$imei = $_POST['imei']; // IMEI or SERIAL Number
$apiKey ='veCwe-bzgzE-JP9NE-ZHEaS-PxFuq-rnmLz';
$service = $_POST['service']; // Service ID
$balanceUrl = 'https://alpha.imeicheck.com/api/php-api/balance?key='.$apiKey;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $balanceUrl);
curl_setopt($ch, CURLOPT_POST, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
$balance = curl_exec($ch);
curl_close($ch);
if ($balance == '{"balance":"0.00"}') {
return redirect()->back()->with('error', 'balance 0.00!');
}
if ($service != 'demo') {
$service = preg_replace("/[^0-9]+/", "", $service);
}
if (strlen($service) > 4 || $service > 250) {
return redirect()->back()->with('error', 'Service ID is Wrong!');
}
if (!filter_var($imei, FILTER_VALIDATE_EMAIL)) {
if (strlen($imei) < "11" || strlen($imei) > "15") {
return redirect()->back()->with('error', 'IMEI or SN is Wrong!');
}
}
$curl = curl_init ("https://alpha.imeicheck.com/api/php-api/create?format='.$format.'&key='.$apiKey.'&service='.$service.'&imei='.$imei");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 60);
curl_setopt($curl, CURLOPT_TIMEOUT, 60);
$result = curl_exec($curl);
curl_close($curl);
return redirect()->back()->with('success', PHP_EOL.$result);
// // echo PHP_EOL."<br/><br/>".PHP_EOL.$result; // Here the result is printed
}

我想在提交后得到带有甜蜜警报的结果,但不工作如何将$result重定向回成功

所以有人解决了这个问题,请让我

因为结果不显示

另一种解决方案

感谢

您可以尝试此代码

<script type="text/javascript">
Swal.fire({
position: 'center',
@if (Session::has('success'))
icon: 'success',
title: "{!! Session::get('success') !!}",
@endif
@if (Session::has('error'))
icon: 'error',
title: "{!! Session::get('error') !!}",
@endif
showConfirmButton: false,
timer: 2500
})
</script>

或者你可以在刀片文件中使用这个

@dd(session()->all());

最新更新