Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
You can't do that. ->with() is the magic that takes care of how to get the data out. You specify the necessary conditions in the callback, but then ->with() calls ->get() and resolves everything itself. In addition, get returns an EloquentCollection, on which all further work with relations is based, and with your actions you are trying to slip a pagination object into it. Obviously this won't work.
Your variable is called model, so I assumed there was only one. In this case, this option will work:
If you need to do this for several models at once, then this is done only by separate requests. ->with() will not help there either, only the above code in the loop.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question