3 namespace BookStack\Exports\ZipExportModels;
5 use BookStack\Entities\Models\Page;
6 use BookStack\Entities\Tools\PageContent;
7 use BookStack\Exports\ZipExportFiles;
9 class ZipExportPage implements ZipExportModel
11 public ?int $id = null;
13 public ?string $html = null;
14 public ?string $markdown = null;
15 public ?int $priority = null;
16 /** @var ZipExportAttachment[] */
17 public array $attachments = [];
18 /** @var ZipExportImage[] */
19 public array $images = [];
20 /** @var ZipExportTag[] */
21 public array $tags = [];
23 public static function fromModel(Page $model, ZipExportFiles $files): self
25 $instance = new self();
26 $instance->id = $model->id;
27 $instance->name = $model->name;
28 $instance->html = (new PageContent($model))->render();
30 if (!empty($model->markdown)) {
31 $instance->markdown = $model->markdown;
34 $instance->tags = ZipExportTag::fromModelArray($model->tags()->get()->all());
35 $instance->attachments = ZipExportAttachment::fromModelArray($model->attachments()->get()->all(), $files);