<?php

$inspirations = $page->children()->map(function ($child) {
  return [
    'title' => $child->title()->value(),
    'description' => $child->description()->value(),
    'new' => $child->new()->value() === "true" ? true : false,
    'date' => $child->date()->toDate('Y-MM-d'),
    'url' => $child->url(),
    'uri' => $child->uri(),
    'modified' => $child->modified('Y-MM-d'),
    'status' => $child->status(),
    'cover' => $child->cover()->toFile()->url(),
    'media' => $child->media()->toFiles()->map(function ($file) {
      return [
        'url' => $file->url(),
        'alt' => $file->alt()->value(),
        'favoriteForUsers' => $file->favoriteForUsers()->value(),
        'name' => $file->filename()
      ];
    })->values()
  ];
})->values();

$specificData = [
  "inspirations" => $inspirations
];

$data = array_merge($genericData, $specificData);

echo json_encode($data);