3 namespace BookStack\Exports\ZipExports\Models;
5 use BookStack\Exports\ZipExports\ZipExportFiles;
6 use BookStack\Exports\ZipExports\ZipValidationHelper;
7 use BookStack\Uploads\Image;
8 use Illuminate\Validation\Rule;
10 class ZipExportImage extends ZipExportModel
12 public ?int $id = null;
17 public static function fromModel(Image $model, ZipExportFiles $files): self
19 $instance = new self();
20 $instance->id = $model->id;
21 $instance->name = $model->name;
22 $instance->type = $model->type;
23 $instance->file = $files->referenceForImage($model);
28 public function metadataOnly(): void
33 public static function validate(ZipValidationHelper $context, array $data): array
36 'id' => ['nullable', 'int', $context->uniqueIdRule('image')],
37 'name' => ['required', 'string', 'min:1'],
38 'file' => ['required', 'string', $context->fileReferenceRule()],
39 'type' => ['required', 'string', Rule::in(['gallery', 'drawio'])],
42 return $context->validateData($data, $rules);
45 public static function fromArray(array $data): self
49 $model->id = $data['id'] ?? null;
50 $model->name = $data['name'];
51 $model->file = $data['file'];
52 $model->type = $data['type'];