3 namespace BookStack\Exports\ZipExports\Models;
5 use BookStack\Activity\Models\Tag;
6 use BookStack\Exports\ZipExports\ZipValidationHelper;
8 class ZipExportTag extends ZipExportModel
11 public ?string $value = null;
12 public ?int $order = null;
14 public function metadataOnly(): void
16 $this->value = $this->order = null;
19 public static function fromModel(Tag $model): self
21 $instance = new self();
22 $instance->name = $model->name;
23 $instance->value = $model->value;
24 $instance->order = $model->order;
29 public static function fromModelArray(array $tagArray): array
31 return array_values(array_map(self::fromModel(...), $tagArray));
34 public static function validate(ZipValidationHelper $context, array $data): array
37 'name' => ['required', 'string', 'min:1'],
38 'value' => ['nullable', 'string'],
39 'order' => ['nullable', 'integer'],
42 return $context->validateData($data, $rules);
45 public static function fromArray(array $data): self
49 $model->name = $data['name'];
50 $model->value = $data['value'] ?? null;
51 $model->order = isset($data['order']) ? intval($data['order']) : null;