如何在Laravel中添加变量

发布于 2025-01-20 07:12:15 字数 646 浏览 5 评论 0原文

我有一个控制器方法来更新数据库中的记录:

$brand_owner_relation = Relation::where('rel_brand_id',$id)->where('rel_is_active',0)->first();

$brand_owner_relation->rel_status_id = 10;
$brand_owner_relation->save();

return redirect()->back()->with('message',"Brand
       {{ $brand_owner_relation->brand_name }}
       is now active
");

现在更新数据的过程工作正常,但我需要将刀片中的品牌名称显示为会话。

所以我尝试过:

return redirect()->back()->with('message',"Brand
       {{ $brand_owner_relation->brand_name }}
       is now active
");

但这是错误的,因为它没有将品牌名称显示为会话值...

因此,如果您知道如何将品牌名称显示为会话值,请告诉我。

I have a Controller method that updates a record in the DB:

$brand_owner_relation = Relation::where('rel_brand_id',$id)->where('rel_is_active',0)->first();

$brand_owner_relation->rel_status_id = 10;
$brand_owner_relation->save();

return redirect()->back()->with('message',"Brand
       {{ $brand_owner_relation->brand_name }}
       is now active
");

Now the process of updating data is working fine but I need to show the Brand Name in the Blade as session.

So I tried :

return redirect()->back()->with('message',"Brand
       {{ $brand_owner_relation->brand_name }}
       is now active
");

but this is wrong cause it does not shows the brand name as session value...

So if you know how to show brand name as session value, please let me know.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

山有枢 2025-01-27 07:12:15
Session::set('brand_name' , $brand_owner_relation->brand_name);
Session::set('brand_name' , $brand_owner_relation->brand_name);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文