Closed diegomagikal closed 4 years ago
Hi @diegomagikal,
The reason for this is because creator()
isn't a relationship on the Thread
model, but just a getter method. So you'll have to get the thread first, then call for the creator.
$thread = Thread::findOrFail($id);
$creator = $thread->creator();
if you'd like to eager load the users, you can do that with
$thread = Thread::with('participants.user')->findOrFail($id);
Using Laravel v7.X laravel-messenger v2.20
Hello,
I get this error when using the
creator
relationship fromThread
model:Call to undefined method User::addEagerConstraints()
I'm trying to get the creator id in
show.blade.php
, adding the following code inMessagesController
:$thread = Thread::with('creator')->findOrFail($id);