default currency and all currencies head issue solved, close #3218
This commit is contained in:
parent
464ed1453d
commit
f5da00b7df
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
namespace App\Listeners\Common;
|
||||
|
||||
use Illuminate\Routing\Events\PreparingResponse as Event;
|
||||
|
||||
class PreparingResponse
|
||||
{
|
||||
/**
|
||||
* Handle the event.
|
||||
*
|
||||
* @param Event $event
|
||||
* @return void
|
||||
*/
|
||||
public function handle(Event $event): void
|
||||
{
|
||||
if (! $event->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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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',
|
||||
],
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
namespace App\View\Components\Layouts\Admin;
|
||||
|
||||
use App\Abstracts\View\Component;
|
||||
|
||||
class Head extends Component
|
||||
{
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.layouts.admin.head');
|
||||
}
|
||||
}
|
||||
|
|
@ -42,8 +42,8 @@
|
|||
<script type="text/javascript"><!--
|
||||
var url = '{{ url("/" . company_id()) }}';
|
||||
var app_url = '{{ config("app.url") }}';
|
||||
var aka_currency = {!! !empty($currency) ? $currency : 'false' !!};
|
||||
var all_currencies = {!! !empty($currencies) ? $currencies : '[]' !!};
|
||||
var aka_currency = {!! !empty($currency) ? json_encode($currency) : 'false' !!};
|
||||
var all_currencies = {!! !empty($currencies) ? json_encode($currencies) : '[]' !!};
|
||||
//--></script>
|
||||
|
||||
<x-script.exceptions.trackers />
|
||||
|
|
|
|||
Loading…
Reference in New Issue