#relation not working

1 messages · Page 1 of 1 (latest)

primal pasture
raven path
#

How are you trying to retrieve the relation?

primal pasture
#

.

#

$mediafile = $course->mediafiles()->where('id', $fileId)->first();

raven path
#

.... if you already have the $fileId why not just call MediaFile::find($fileId)?

primal pasture
#

just ignore it i need to rewrite it i dont have it ahhahahah

#

imagine there is only $mediafile = $course->mediafile()

raven path
#

mediaFile() doesn't exist though. Your relation is mediaFiles?

primal pasture
#

yeah mediafiles forgot the s

raven path
#

Is that you you're trying to retrieve them?

#

You're getting the relationship object

primal pasture
#

i dont get anything i try to retrieve mediafiles from the relation but i dont get it

raven path
#

$mediaFiles = $course->mediaFiles

#

Or $mediaFiles = $course->mediaFiles()->get()

primal pasture