I have media results stored in the database with the correct information, model, id etc... But when I try to query the media to pull results my collection is always empty;
$page = Page::where('slug', $p)->firstOrFail();
$media = $page->getMedia();
dd($media);
When I use $media = $page->Media(); the media collection is empty.
Issue resolved you have to pass a collection name to getMedia(); if you're not using the "default" collection. in my instance getmedia('banner');
Thank you for posting your solution. I was about to tear my hair out trying to figure out why this wasn't working. The docs should definitely address this if they don't already (I didn't see this noted anywhere)
Yes, I also don't see it in the documentation, worth updating to accommodate. Well done on resolving your issue!
Most helpful comment
Thank you for posting your solution. I was about to tear my hair out trying to figure out why this wasn't working. The docs should definitely address this if they don't already (I didn't see this noted anywhere)