id = $model->id; $instance->name = $model->name; if ($model->external) { $instance->link = $model->path; } else { $instance->file = $files->referenceForAttachment($model); } return $instance; } public static function fromModelArray(array $attachmentArray, ZipExportFiles $files): array { return array_values(array_map(function (Attachment $attachment) use ($files) { return self::fromModel($attachment, $files); }, $attachmentArray)); } }