Yin*_*ing 7 laravel laravel-5 laravel-notification
我将通知保存到数据库中,如下所示:
public function toDatabase($notifiable)
{
return [
'from' => $this->message->name,
'name'=> $this->message->email,
'subject' => $this->message->subject,
'body' => $this->message->body
];
}
Run Code Online (Sandbox Code Playgroud)
它工作正常。现在我想将这些数据提取到我的视图中,所以我这样做:
@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
Run Code Online (Sandbox Code Playgroud)
但它什么也没给我。所以我做错了吗?
Chr*_*hvh 10
从注释中注意到Notification对象具有data属性,所有数据都存储在该属性中,以便访问它:
更改:
{{ $notification->name }}
Run Code Online (Sandbox Code Playgroud)
至
{{ $notification->data['name'] }}
Run Code Online (Sandbox Code Playgroud)
并针对您的所有数据执行此操作。
| 归档时间: |
|
| 查看次数: |
4900 次 |
| 最近记录: |