php - 中间件干扰会话消息
问题描述
我正在开发一个仪表板,我正在尝试处理错误,为此我在 handler.php 上有这段代码
public function render($request, Throwable $e)
{
if($e instanceof \Symfony\Component\HttpKernel\Exception\NotFoundHttpException)
{
if(Auth::user() && (Auth::user()->isStaff() || Auth::user()->isAdmin()))
{
return response()->view('dashboard.404error', [], 404);
}
return response()->view('404error', [], 404);
}
elseif ($e instanceof \Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException) {
return response()->view('405error', [], 405);
}
// elseif($this->isHttpException($e) && $e->getStatusCode() == '405')
// {
// return response()->view('404error', [], 404);
// }
return parent::render($request, $e);
}
但是要检查用户是否登录以及它是什么类型,我必须在 kernel.php 上添加这个中间件:
中间件:
\Illuminate\Session\Middleware\StartSession::class,
但我不知道为什么在那之后我的弹出窗口在我编辑或创建一个员工时停止出现,我不知道为什么。
通常在视图中,我会用以下内容返回它们:
return redirect()->route('admin.operadoras')
->with('alert-msg', 'Staff edited with success')
->with('alert-type', 'danger');
我对刀片视图的看法是:
@if (session('alert-msg'))
@include('partials.message')
@endif
我不知道为什么那个中间件会干扰这个消息。
解决方案
推荐阅读
- c++ - 传递动态分配的二维字符数组会导致分段错误?
- python - 不必在第一行打印“x”。怎么办?
- reactjs - REACTJS 和 ANTD:如何通过
- datalog - Disjunctions in DataLog
- django - 如何在 django 中使用模型的外部字段设置字段的初始值?
- reactjs - 未找到模块:错误:无法解析(多个错误)
- apache-spark - 清理 emr 集群上的 spark 流历史
- powershell - 如何处理循环使用powershell创建文件?
- javascript - 日期未在数据库中保存正确的值
- pyspark - Converting string time to day timestamp