laravel-video-chat
laravel-video-chat copied to clipboard
Trying to get property 'conversation' of non-object
I have just tried to run your demo codes after everything has been installed into the domain server. The error encountered into my laravel 7 application. Let me show you where actually the issue occurred. This is home.blade.php
@foreach($threads as $inbox)
@if($inbox->message->conversation->is_accepted) <!-- This is the line of code where error has been encountered -->
<a href="{{ route('chat' , [
'id' => $inbox->message->conversation->id
]) }}">
<div class="about">
<div class="name">{{$inbox->user->name}}</div>
<div class="status">
@if(auth()->user()->id == $inbox->message->sender->id)
<span class="fa fa-reply"></span>
@endif
<span>{{ substr($inbox->message->text, 0, 20)}}</span>
</div>
</div>
</a>
@else
<a href="#">
<div class="about">
<div class="name">{{$inbox->user->name}}</div>
<div class="status">
@if(auth()->user()->id == $inbox->message->sender->id)
<span class="fa fa-reply"></span>
@endif
<span>{{ substr($inbox->message->text, 0, 20)}}</span>
</div>
@if($inbox->message->conversation->second_user_id == auth()->user()->id)
<div>
<a href="{{ route('accept.message' , [
'id' => $inbox->message->conversation->id
]) }}" class="btn btn-xs btn-success">Accept Message Request</a>
</div>
@endif
</div>
</a>
@endif
@endforeach
This is HomeController.php index()
public function index()
{
$groups = Chat::getAllGroupConversations();
$threads = Chat::getAllConversations();
return view('home')->with([
'threads' => $threads,
'groups' => $groups
]);
}
When I dump and die into the $threads[0]->message, I find #relations null