$document * @param array $payload */ public function handle(string $document, array $payload): BaseCompiler { return Tex::compile($document::fromRequest($payload)); } public function asController(ActionRequest $request): BaseCompiler { $payload = $this->payload($request); $type = data_get($payload, 'type'); ValidateAction::validateType($type); Validator::make($payload, app(ContributionFactory::class)->rules($type))->validate(); return $this->handle($type, $payload); } /** * @return array */ public function rules(): array { return [ 'payload' => [new JsonBase64Rule()], ]; } /** * @return array */ private function payload(ActionRequest $request): array { return json_decode(base64_decode($request->input('payload', '')), true); } }