34 lines
672 B
PHP
34 lines
672 B
PHP
<?php
|
|
|
|
namespace App\Livewire;
|
|
|
|
use App\Models\Client;
|
|
use App\Models\User;
|
|
use Livewire\Component;
|
|
|
|
class ClientSwitch extends Component
|
|
{
|
|
public $clients = [];
|
|
|
|
public ?string $client = '';
|
|
|
|
public function mount()
|
|
{
|
|
$this->clients = Client::pluck('name', 'id')->all();
|
|
|
|
$this->client = Client::where('id', auth()->user()->client_id)->pluck('name')->first();
|
|
}
|
|
|
|
public function render()
|
|
{
|
|
return view('livewire.client-switch');
|
|
}
|
|
|
|
public function swop($client_id)
|
|
{
|
|
User::where('id', auth()->user()->id)->update(['client_id' => $client_id]);
|
|
|
|
$this->js('window.location.reload()');
|
|
}
|
|
}
|