Method addEagerConstraints does not exist

后端 未结 2 413
悲&欢浪女
悲&欢浪女 2021-01-12 18:06

I have two models, User and Event. I made a pivot table, invitations between User and Event with a status column. In my Event model definition, I w

相关标签:
2条回答
  • 2021-01-12 18:45

    When you're trying to do this:

    ->with('participants')
    

    Laravel expects to get a relationship instance. In other words, you can't use this method as a relation.

    0 讨论(0)
  • 2021-01-12 18:46

    where should come before with. This is what eloquent expects.

    It should be like this:

    $event = Event::with(['owner', 'participants'])->where('id', $id)->first();
    
    0 讨论(0)
提交回复
热议问题