【发布时间】:2021-09-16 10:24:06
【问题描述】:
我正在尝试向一个函数提交几个请求,该函数将它们写入一个会话,然后返回它们
这里我将数据提交给函数
$this->Notification->build('error', 'Test', 'danger', 'bottom-left', 0, 'true');
$this->Notification->build('error', 'Test1', 'danger', 'bottom-left', 0, 'true');
这是我们使用的函数
public function build($title, $description, $type, $position, $closeTimeout, $showProgress)
{
$notify = '<script>';
$notify .= 'Notification.notify({';
$notify .= 'title: "'.esc($title).'",';
$notify .= 'description: "'.esc($description).'",';
$notify .= 'image: {visible: true},';
$notify .= 'type: "'.$type.'",';
$notify .= 'position: "'.$position.'",';
$notify .= 'closeTimeout: "'.$closeTimeout.'",';
$notify .= 'showProgress: "'.$showProgress.'",';
//$notify. .= '';
//$notify. .= '';
//$notify. .= '';
//$notify. .= '';
$notify .= '});</script>';
$notify = $this->Session->setFlashData("notify", $notify); // records a session named "notify"
return true;
}
通话会话
<?php if (session()->get('notify')) : ?>
<?= session()->get('notify'); ?>
<?php endif; ?>
当它执行脚本时,它只返回最后一个请求 - $this->Notification->build('error', 'Test1', 'danger', 'bottom-left', 0, 'true');
【问题讨论】:
-
你不只是重写你的会话
notify键吗?最后写入获胜... -
如何让它保存许多查询