douqie6454 2016-01-23 00:52
浏览 31

app.blade.php布局没有看到更新的用户信息

I'm building a site using Laravel 5.2. I have a function that simply changes one attribute of a user. It changes the "type" attribute from "individual" to "business". The function is simple and changes the database. It looks like this:

public function addBusiness() {
    $user = Auth::user()->update([
        'type' => 'business'
    ]);

    Session::flash('msg_title', 'Awesome!');
    Session::flash('message', 'You\'ve added a business to your account');
    return redirect()->back(); 

}

If I display the attribute in the body it displays business as it should.

However, in the header (located in the layout app.blade.php file) it still shows "individual." I did a test where I had {{Auth::user()->type}} in both app.blade.php and my body blade file, it displayed "individual" in app.blade.php, and "business" in the body on the same screen.

It even persists after Session::flush(); after logout/login, or even login from another browser.

  • 写回答

1条回答 默认 最新

  • dongxun1142 2016-01-23 01:21
    关注

    try \Auth::setUser($user) after updating user

    check def in laravel/framework/src/Illuminate/Auth/Guard::setUser

    评论

报告相同问题?

悬赏问题

  • ¥15 Mac系统vs code使用phpstudy如何配置debug来调试php
  • ¥15 目前主流的音乐软件,像网易云音乐,QQ音乐他们的前端和后台部分是用的什么技术实现的?求解!
  • ¥60 pb数据库修改与连接
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)