I have a set of blog posts, most of which have a project associated with them. If the blog post has an image, that is shown. If the blog post has no image, but it has a corresponding project, then the first image of that project is shown. At least, that’s what I’m trying to create.
However, the line $testimage = page($article->project())->images()->sortBy('sort', 'asc')->first(); ?> does not work. This is the output: Error thrown with message "Call to a member function images() on boolean".
Well, yes, but what does the string contain? The UID of the project or the path to the page? Because the page() helper requires a path to a page. If you store the UID (i.e. only project-a for example), page('project-a') will not get you anywhere, you need to get the page like this:
page('projects/project-a')
And don’t forget to use an if statement to test for $testimage before calling the thumb method.