【发布时间】:2019-12-19 23:28:43
【问题描述】:
我正在使用 laravel 5.8 和 "laracasts/flash": "^3.0"
在我的应用程序中,除了这段非常特殊的代码之外,所有重定向和 Flash 消息都运行良好。
/* Controller */
public function show( Test $test) {
$test->checkPermission();
...
}
/* Model */
public function checkPermission()
{
flash()->warning('You can not have access to this.');
return redirect( route('home' ) )->send(); //Notice the send()
}
如果我将此代码与->send()(我以前从未使用过)一起使用,我会很好地重定向到主页,但没有闪烁消息。
如果我删除 ->send(),我会收到 Flash 消息,但我没有重定向。
我还尝试删除flash() 并使用redirect()->with()。然后会话包含消息和我被重定向。但我想使用flash() 或至少了解为什么它不适用于这个特定的用例。
【问题讨论】:
标签: laravel session redirect laravel-5 laravel-5.8