Files
nuhodds_fi4/app/Livewire/KontoSwitcher.php
T
2026-01-29 20:20:31 +01:00

45 lines
1.1 KiB
PHP

<?php
namespace App\Livewire;
use App\Models\Client;
use App\Models\User;
use Livewire\Component;
class KontoSwitcher extends Component
{
public $clients = [];
public function mount()
{
$this->clients = Client::where('id', '!=', auth()->user()->client_id)->pluck('name', 'id')->all();
}
public function swopClient($client_id)
{
$providers = Client::where('id', $client_id)->pluck('provider')->first();
$provider_id = array_shift($providers);
$bookmakers = Client::where('id', $client_id)->pluck('bookmaker')->first();
$bookmaker_id = array_shift($bookmakers);
$partner_bookmaker_id = array_shift($bookmakers) ?? 0;
User::where('id', auth()->user()->id)->update([
'sport_id' => 1,
'provider_id' => $provider_id,
'bookmaker_id' => $bookmaker_id,
'partner_bookmaker_id' => $partner_bookmaker_id,
'client_id' => $client_id,
]);
$this->js('window.location.reload()');
}
public function render()
{
return view('livewire.konto-switcher');
}
}