parsedParams; $result = [ 'id' => $model->uuid, 'slug' => $model->slug, 'link' => $model->link, 'type' => 'publication', 'subtype' => $model->parsedType, 'params' => $params, 'name' => $model->name, 'excerpt' => $model->excerpt, 'publish_date_rus' => $model->publish_date_rus, 'is_published' => boolval($model->is_published), 'published_at' => $model->published_at ? $model->published_at->toIso8601String() : null, 'created_at' => $model->created_at ? $model->created_at->toIso8601String() : null, 'updated_at' => $model->updated_at ? $model->updated_at->toIso8601String() : null ]; if ($model->parsedType['name'] === PublicationType::PHOTOS && $params->assets) { $models = Asset::query()->whereIn('uuid', $params->assets)->orderBy('id')->get(); $result['assets'] = fractal($models, new AssetTransformer()); } return $result; } public function includePage(Publication $model): ?Item { return $model->page ? $this->item($model->page, new PageTransformer()) : null; } public function includeParents(Publication $model): Collection { return $this->collection($model->parents->reverse(), new PageTransformer()); } public function includePoster(Publication $model): ?Item { return $model->poster ? $this->item($model->poster, new AssetTransformer()) : null; } public function includeAuthor(Publication $model): ?Item { return $model->author ? $this->item($model->author, new UserTransformer()) : null; } public function includeSections(Publication $model): Collection { return $this->collection($model->sections, new ObjectTransformer()); } public function includeSidebars(Publication $model): Collection { return $this->collection($model->sidebars, new ObjectTransformer()); } public function includePermissions(Publication $model): Primitive { return $this->primitive((new PermissionsService($model))->get()); } }