diff --git a/app/Listeners/Common/PreparingResponse.php b/app/Listeners/Common/PreparingResponse.php new file mode 100644 index 000000000..61a3e3579 --- /dev/null +++ b/app/Listeners/Common/PreparingResponse.php @@ -0,0 +1,34 @@ +response instanceof \Illuminate\View\View) { + return; + } + + $data = $event->response->getData(); + + // Head components currency and all currencies variables + foreach (['currencies', 'currency'] as $key) { + if (! isset($data[$key])) { + continue; + } + + $value = $data[$key] ?? null; + + view()->share($key, $value); + } + } +} diff --git a/app/Providers/Event.php b/app/Providers/Event.php index 4bd37c575..fbb3690be 100644 --- a/app/Providers/Event.php +++ b/app/Providers/Event.php @@ -32,6 +32,9 @@ class Event extends Provider 'App\Listeners\Update\V31\Version318', 'App\Listeners\Update\V31\Version3112', ], + 'Illuminate\Routing\Events\PreparingResponse' => [ + 'App\Listeners\Common\PreparingResponse', + ], 'Illuminate\Auth\Events\Login' => [ 'App\Listeners\Auth\Login', ], diff --git a/app/View/Components/Form/Group/Account.php b/app/View/Components/Form/Group/Account.php index 112211465..61d170651 100644 --- a/app/View/Components/Form/Group/Account.php +++ b/app/View/Components/Form/Group/Account.php @@ -60,6 +60,9 @@ class Account extends Form $this->selected = setting('default.account'); } + // Share accounts with all views + view()->share('accounts', $this->accounts); + return view('components.form.group.account'); } diff --git a/app/View/Components/Layouts/Admin/Head.php b/app/View/Components/Layouts/Admin/Head.php new file mode 100644 index 000000000..0344a879b --- /dev/null +++ b/app/View/Components/Layouts/Admin/Head.php @@ -0,0 +1,18 @@ +