2025-04-09 19:25:15 -05:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
use App\Models\Currency;
|
|
|
|
|
use App\Models\User;
|
|
|
|
|
use Illuminate\Support\Collection;
|
|
|
|
|
use Livewire\Volt\Component;
|
|
|
|
|
|
|
|
|
|
new class extends Component
|
|
|
|
|
{
|
|
|
|
|
// props
|
|
|
|
|
|
|
|
|
|
public Collection $currencies;
|
|
|
|
|
|
|
|
|
|
public string $display_currency;
|
|
|
|
|
|
|
|
|
|
public ?string $locale;
|
|
|
|
|
|
|
|
|
|
public ?User $user;
|
|
|
|
|
|
|
|
|
|
// methods
|
|
|
|
|
public function rules()
|
|
|
|
|
{
|
|
|
|
|
return [
|
|
|
|
|
'locale' => ['required', 'in:'.implode(',', Arr::pluck(config('app.available_locales'), 'locale'))],
|
|
|
|
|
'display_currency' => ['required', 'exists:currencies,currency'],
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function mount()
|
|
|
|
|
{
|
|
|
|
|
$this->currencies = Currency::get();
|
|
|
|
|
$this->display_currency = auth()->user()->getCurrency();
|
|
|
|
|
$this->locale = auth()->user()->getLocale();
|
|
|
|
|
$this->user = auth()->user();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function updateProfileInformation()
|
|
|
|
|
{
|
|
|
|
|
$this->resetErrorBag();
|
|
|
|
|
|
|
|
|
|
$this->validate();
|
|
|
|
|
|
2025-04-10 20:47:35 -05:00
|
|
|
$this->user->setOption([
|
2025-04-09 19:25:15 -05:00
|
|
|
'locale' => $this->locale,
|
|
|
|
|
'display_currency' => $this->display_currency,
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$this->user->save();
|
|
|
|
|
|
|
|
|
|
cache()->tags(['metrics-'.$this->user->id])->flush();
|
|
|
|
|
|
|
|
|
|
$this->dispatch('saved');
|
|
|
|
|
|
2025-04-10 20:47:35 -05:00
|
|
|
// $this->js('window.location.reload();');
|
2025-04-09 19:25:15 -05:00
|
|
|
}
|
|
|
|
|
}; ?>
|
2025-09-26 17:41:28 -05:00
|
|
|
|
2025-04-09 19:25:15 -05:00
|
|
|
<x-forms.form-section submit="updateProfileInformation">
|
|
|
|
|
<x-slot name="title">
|
|
|
|
|
{{ __('Locale Options') }}
|
|
|
|
|
</x-slot>
|
|
|
|
|
|
|
|
|
|
<x-slot name="description">
|
|
|
|
|
{{ __('Adjust localization options for your preferred region.') }}
|
|
|
|
|
</x-slot>
|
|
|
|
|
|
|
|
|
|
<x-slot name="form">
|
|
|
|
|
|
|
|
|
|
<div class="col-span-6 sm:col-span-4">
|
2025-09-26 17:41:28 -05:00
|
|
|
<x-ui.select
|
2025-04-09 19:25:15 -05:00
|
|
|
label="{{ __('Locale') }}"
|
2026-03-18 20:23:51 -05:00
|
|
|
class=""
|
2025-04-09 19:25:15 -05:00
|
|
|
:options="config('app.available_locales')"
|
|
|
|
|
option-value="locale"
|
|
|
|
|
option-label="label"
|
|
|
|
|
placeholder="Choose a locale"
|
|
|
|
|
wire:model="locale"
|
|
|
|
|
id="locale"
|
2025-09-26 17:41:28 -05:00
|
|
|
required
|
2025-04-09 19:25:15 -05:00
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="col-span-6 sm:col-span-4">
|
2025-09-26 17:41:28 -05:00
|
|
|
<x-ui.select
|
2025-04-09 19:25:15 -05:00
|
|
|
label="{{ __('Display Currency') }}"
|
2026-03-18 20:23:51 -05:00
|
|
|
class=""
|
2025-04-09 19:25:15 -05:00
|
|
|
:options="$currencies"
|
|
|
|
|
option-value="currency"
|
|
|
|
|
option-label="label"
|
|
|
|
|
placeholder="Choose a display currency"
|
|
|
|
|
wire:model="display_currency"
|
|
|
|
|
id="display_currency"
|
2025-09-26 17:41:28 -05:00
|
|
|
required
|
2025-04-09 19:25:15 -05:00
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</x-slot>
|
|
|
|
|
|
|
|
|
|
<x-slot name="actions">
|
|
|
|
|
<x-forms.action-message class="me-3" on="saved">
|
|
|
|
|
{{ __('Saved.') }}
|
|
|
|
|
</x-forms.action-message>
|
|
|
|
|
|
2025-09-26 17:41:28 -05:00
|
|
|
<x-ui.button type="submit">
|
2025-04-09 19:25:15 -05:00
|
|
|
{{ __('Save') }}
|
2025-09-26 17:41:28 -05:00
|
|
|
</x-ui.button>
|
2025-04-09 19:25:15 -05:00
|
|
|
</x-slot>
|
|
|
|
|
</x-forms.form-section>
|