Files
nuhodds_fi4/app/Livewire/TopMenuItems.php
T
2025-12-26 10:42:51 +01:00

69 lines
1.6 KiB
PHP

<?php
namespace App\Livewire;
use App\Models\Client;
use App\Models\Sport;
use App\Models\User;
use Illuminate\Support\Facades\Route;
use Livewire\Component;
class TopMenuItems extends Component
{
public $clients = [];
public ?string $client = '';
public $sports = [];
public $sport_id = 0;
public $sporticon = '';
public $iconcolor = '';
public $current = '';
public function mount()
{
$cps = Client::where('id', auth()->user()->client_id)->pluck('sport')->first();
$this->sports = Sport::whereIn('id', $cps)->pluck('name', 'id');
$this->sporticon = Sport::where('id', auth()->user()->sport_id)->pluck('icon')->first();
$this->iconcolor = Sport::where('id', auth()->user()->sport_id)->pluck('color')->first();
$this->sport_id = auth()->user()->sport_id;
$this->clients = Client::pluck('name', 'id')->all();
$this->client = Client::where('id', auth()->user()->client_id)->pluck('name')->first();
$this->current = Route::currentRouteName();
}
public function render()
{
return view('livewire.top-menu-items');
}
public function swop($client_id)
{
$bookmakers = Client::where('id', $client_id)->pluck('bookmaker')->first();
$bookmaker_id = array_shift($bookmakers);
User::where('id', auth()->user()->id)->update(['bookmaker_id' => $bookmaker_id, 'client_id' => $client_id]);
$this->js('window.location.reload()');
}
public function swopSport()
{
User::where('id', auth()->user()->id)->update(['sport_id' => $this->sport_id]);
$this->js('window.location.reload()');
}
}