使用队列后,新建话题成功后没有消息提示?
为什么使用队列后新建话题不显示提示消息?
public function store(TopicRequest $request,Topic $topic)
{
$topic->fill($request->all()); //fill 方法会将传参的键值数组填充到模型的属性中
$topic->user_id = Auth::id(); //赋值属性
$topic->save(); //保存入库
dump($topic->link());
return redirect()->to($topic->link())->with('message', '成功创建话题!');
}
这里保存入库时调用监视器,监视器推送队列任务去翻译字段。
保存之后跳转到$topic->link()
,打印出来是http://larabbs2.test/topics/120
,是没有slug参数的路由,可是继续访问,又跳转到了有sulg的链接,应该是连续跳转了2次吧,导致第一次跳转携带的with('message', '成功创建话题!');
没了?
推荐文章: