Although a similar question is asked but in a different context here. Laravel Eloquent with and find
Issue I am having right now is that when I use "find", it returns the object and not the collection.
MyModel::find($myId)
But when I use "with" it returns me the collection. Shouldn't be a single object with eager loading all the required data ?
MyModel::find($myId)->with('notes')
I am expecting it to return a single object with eager loading the notes. But its returning the collection. So I have to get the first object of the collection and then the eager loaded notes in it. But when I do something like
MyModel::find($myId)->with('notes')->first()
It returns the single object, which is correct, but doesn't make sense to me as I have read on laracast forum that "first" behind the scene uses "find". So do I really need to use "find" and "first" together to get the required data or is there something I am doing wrong ?
P.S I am using Laravel 5.3