在Laravel 10 liveire 3中,我显示用户通知列表:
namespace App\Livewire\Personal;
use Livewire\WithPagination;
class ProfileEditor extends Component
{
use WithPagination;
public $notifications;
public int $notificationsPage= 1;
public bool $notificationsOnlyUnread= true;
public function render(): View
{
$this->notifications = auth()->user()->notifications()->latest()->paginate(2);
return view('livewire.personal.profile-editor')->layout('components.layouts.personal');
}
但在Blade中我遇到了错误:
Livewire中不支持属性的属性类型:[{"当前_页面":1,"数据":[{"id":"f4 bec 30 e-e661 - 4f 91-aafd-a9 ae 623 CF269","类型":"App\ ...
在模板行中
<table class="editor_listing_table mb-4">
<thead class="editor_listing_table_header">
<tr>
<td>
<h3 class="personal_subtitle">
Your Notifications
</h3>
</td>
</tr>
</thead>
@foreach($notifications as $notification)
{{-- {{ dd($notification)--}}
<tr>
<td class="editor_listing_cell whitespace-nowrap">
{{$notification->notifiable_id}}
</td>
<td class="editor_listing_cell whitespace-nowrap">
{{$notification->notifiable_type}}
</td>
</tr>
@endforeach
</table>
@if(count($notifications) > 0)
<div class="livewire-pagination">
{{ $notifications->onEachSide(2)->links(data: ['scrollTo' => false]) }}
</div>
@endif
如果要取消 comments 行
dd($notification)
我看到:
With DatabaseNotification class for any row item.
如果在dd中使用toArray方法,我会看到有效的数据行,但无论如何,这
不支持属性类型.
错误并且我不知道如何修复它?事实上,我没有在Blade 文件中引用"类型"字段