Пытался следовать этому уроку Laravel показать последний ответ, оставленный на посте , работал, но теперь возвращается в некоторые темы с этой ошибкой здесь
Trying to get property 'author' of non-object (View: /var/www/html/web/resources/views/forums/board.blade.php)
Это мой используемый код:
<h1>{{$board->name}}</h1>
@auth
<a role="button" href="{{route('forums.thread.create', $board->id)}}" class="btn btn-primary">Create Thread</a>
@endauth
@foreach($board->threads->sortByDesc('pinned') as $thread)
<div class="thread-box {{$thread->pinned ? '' : 'bg-light'}} p-3 mt-3" style="background-color: #eee;">
<a href="{{route('forums.thread.show', $thread->id)}}" class="text-decoration-none">
<img src="{{$thread->author->avatar}}" alt="User Avatar" style="max-height: 40px;" class="rounded-circle">
<span>
{{$thread->name}}
</span>
</a>
@if(!$thread->pinned)
@else
<div class=" d-inline lock">
<i class="fas fa-thumbtack"></i>
</div>
@endif
@if(!$thread->locked)
@else
<div class=" d-inline lock">
<i class="fas fa-lock"></i>
</div>
@endif
<hr>
@if($thread->replies)<p>Last Update: <img src="{{$thread->replies->sortBydesc('id')->first()->author->avatar}}" alt="User Avatar" style="max-height: 40px;" class="rounded-circle"> <b>{{$thread->replies->sortBydesc('id')->first()->author->username}}</b></p>@else<p>No New Activity</p>@endif
</div>
@endforeach
</div>
@endsection
Работал раньше, как я уже говорил, но, похоже, больше не работает. Есть идеи?