We've retired the forum in favor of GitHub Discussions.

New conversations can be started on GitHub. Existing conversations will remain for a while longer.

Head over to GitHub →

Statamic v3, using Queries in custom controller and augment cms data

Chris Bachmeier June 11, 2020 by Chris Bachmeier

Hi everyone, I was wondering if there's a way to augment data that has been retrieved through queries in a custom controller. As an example, I have a query to retrieve some of the data from the cms:

$retreat = Collection::find('retreats')
            ->queryEntries()
            ->where('id', $id)
            ->where('published', true)
            ->where('enable_flyer', true)
            ->first();

Is there a way to augment those kind of results so it can be used the Statamic way in a template? As long as there are only simple fields that's not an issue, but when you have more complex data fields like Relations, Bard and so on it would be great to augment those fields so that they can be handled the usual way in a template.

Currently I'm doing further queries to resolve relationships and for Bard it will be stored as html.

Thanks for any suggestions : )

Answered by Chris Bachmeier!
>>>>>>> Answered <<<<<<<
3 Replies
3 Followers