diff --git a/src/Screen/Layout.php b/src/Screen/Layout.php index 662d3c213b..7a6fd7f646 100644 --- a/src/Screen/Layout.php +++ b/src/Screen/Layout.php @@ -92,7 +92,7 @@ public function currentAsync(): self return $this; } - /** + /** * @param Repository $repository * * @return mixed @@ -101,22 +101,12 @@ protected function buildAsDeep(Repository $repository) { $this->query = $repository; - if (! $this->isSee()) { + if (!$this->isSee()) { return; } - $build = collect($this->layouts) - ->map(function ($layouts) { - return Arr::wrap($layouts); - }) - ->map(function (iterable $layouts, string $key) use ($repository) { - return $this->buildChild($layouts, $key, $repository); - }) - ->collapse() - ->all(); - $variables = array_merge($this->variables, [ - 'manyForms' => $build, + 'manyForms' => $this->reparation(), 'templateSlug' => $this->getSlug(), 'asyncEnable' => empty($this->asyncMethod) ? 0 : 1, 'asyncRoute' => $this->asyncRoute(), @@ -125,6 +115,26 @@ protected function buildAsDeep(Repository $repository) return view($this->async ? 'platform::layouts.blank' : $this->template, $variables); } + /** + * @return array + */ + protected function reparation(): array + { + if ($this->asyncMethod && !$this->async) { + return []; + } + + return collect($this->layouts) + ->map(function ($layouts) { + return Arr::wrap($layouts); + }) + ->map(function (array $layouts, string $key) { + return $this->buildChild($layouts, $key, $this->query); + }) + ->collapse() + ->all(); + } + /** * Return URL for screen template requests from browser. *