0

I created a module, in my controller I want to return the entries with the assets in JSON format.

Here is my code.

File: In service class, I am getting the data.

 public function getData($sectionName = null, $offSet = 0)
{   
    if ($sectionName == null) {
        $sectionName = $this->getDefaultSection();
    }
    // Create an entry query and set some parameters on it
    $entryQuery = Entry::find()
        ->section($sectionName)
        ->with('featuredImage') <-----
        ->limit($this->limit);

    // Execute the query and get the results
    $entries = $entryQuery->all();

    if (is_array($entries)) {
        return $entries;
    }
}

I am using ->with() as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.