Add all files

This commit is contained in:
root
2025-11-30 11:57:22 +01:00
parent 2ee51cac4f
commit 044271db3d
1476 changed files with 142544 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
<?php
namespace App\Livewire\Components;
use App\Classes\Cart;
use App\Livewire\Component;
use App\Models\Currency;
class CurrencySwitch extends Component
{
public $currentCurrency;
protected $currencies = [];
public function mount()
{
$this->currentCurrency = session('currency', config('settings.default_currency'));
$this->currencies = Currency::all()->map(fn ($currency) => [
'value' => $currency->code,
'label' => $currency->code,
])->values()->toArray();
if (Cart::get()->isNotEmpty() || count($this->currencies) <= 1) {
$this->skipRender();
}
}
public function updatedCurrentCurrency($currency)
{
if (Cart::get()->isNotEmpty()) {
$this->notify('You cannot change the currency while there are items in the cart.', 'error');
$this->currentCurrency = session('currency', config('settings.default_currency'));
return;
}
session(['currency' => $currency]);
return $this->redirect(request()->header('Referer', '/'), navigate: true);
}
public function render()
{
return view('components.currency-switch');
}
}