gpt4 book ai didi

laravel - 从Laravel中的通知数据库中提取数据

转载 作者:行者123 更新时间:2023-12-04 06:31:29 24 4
gpt4 key购买 nike

我将通知保存到数据库中,如下所示:

public function toDatabase($notifiable)
{
return [
'from' => $this->message->name,
'name'=> $this->message->email,
'subject' => $this->message->subject,
'body' => $this->message->body
];
}

它工作正常。现在我想将这些数据提取到我的 View 中,所以我这样做:
@foreach ( Auth::user()->unreadNotifications as $notification)
<li><!-- start message -->
<a href="#">
<!-- Message title and timestamp -->
<h4>
{{ $notification->name }}
<small><i class="fa fa-clock-o"></i> 5 mins</small>
</h4>
<!-- The message -->
<p>{{ $notification->subject }}</p>
</a>
</li>
@endforeach

但它什么也没给我。所以我做错了吗?

最佳答案

从注释中注意到Notification对象具有data属性,所有数据都存储在该属性中,以便访问它:

改变:

{{ $notification->name }}


{{ $notification->data['name'] }}

并针对您的所有数据执行此操作。

关于laravel - 从Laravel中的通知数据库中提取数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47653232/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com