3 namespace BookStack\Exports\ZipExportModels;
5 use BookStack\Exports\ZipExportFiles;
6 use BookStack\Uploads\Attachment;
8 class ZipExportAttachment implements ZipExportModel
10 public ?int $id = null;
12 public ?int $order = null;
13 public ?string $link = null;
14 public ?string $file = null;
16 public static function fromModel(Attachment $model, ZipExportFiles $files): self
18 $instance = new self();
19 $instance->id = $model->id;
20 $instance->name = $model->name;
22 if ($model->external) {
23 $instance->link = $model->path;
25 $instance->file = $files->referenceForAttachment($model);
31 public static function fromModelArray(array $attachmentArray, ZipExportFiles $files): array
33 return array_values(array_map(function (Attachment $attachment) use ($files) {
34 return self::fromModel($attachment, $files);
35 }, $attachmentArray));