validate(self::shape(required: true)); return $this->respond(EventPresenter::forUser($this->manual->create($this->user(), $fields))); } /** * Поля события — общие для create_event и update_event. Форматы и смысл * (fire_at не позже срока, deep_link — путь или ссылка) проверяет ManualEvents. * * @return array */ public static function fields(JsonSchema $schema, bool $required): array { $title = $schema->string()->max(200)->description('Заголовок напоминания'); $dueAt = $schema->string()->description('Срок: YYYY-MM-DD, YYYY-MM-DDTHH:MM или со смещением'); return [ 'title' => $required ? $title->required() : $title, 'due_at' => $required ? $dueAt->required() : $dueAt, 'subtitle' => $schema->string()->max(200)->description('Подзаголовок'), 'fire_at' => $schema->string()->description('YYYY-MM-DD, день начала подготовки; не позже дня срока'), 'after_due' => $schema->string()->enum(['keep', 'expire'])->description('Что после срока: keep (по умолчанию) или expire'), 'done_label' => $schema->string()->max(64)->description('Подпись кнопки закрытия, по умолчанию «Сделано»'), 'deep_link' => $schema->string()->description('Куда вести из напоминания: относительный путь или http(s)-ссылка'), ]; } /** * Форма аргументов: что передано и какого типа. Остальное — EventRules через ManualEvents. * * @return array> */ public static function shape(bool $required): array { $presence = $required ? 'required' : 'sometimes'; return [ 'title' => [$presence, 'string', 'max:200'], 'due_at' => [$presence, 'string'], 'subtitle' => ['sometimes', 'nullable', 'string', 'max:200'], 'fire_at' => ['sometimes', 'nullable', 'string'], 'after_due' => ['sometimes', 'string'], 'done_label' => ['sometimes', 'nullable', 'string'], 'deep_link' => ['sometimes', 'nullable', 'string'], ]; } }