chrisgrim
1 month ago

Better Understanding of Eager Loading

Posted 1 month ago by chrisgrim

Hi, I have a quick question. In my show method I have

  public function create(Event $event)
    {
return $event
}

Using a wildcard in my url I get the specific event model returned. However if I want to eager load a model with that event I assumed I would use

  public function create(Event $event)
    {

        return $event->with('location')->get();
}

However, that returns all of my events with location eager loaded. How do I just return the individual event with only its locations.

Thanks!

Please sign in or create an account to participate in this conversation.