67 lines
1.6 KiB
PHP
67 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Livewire;
|
|
|
|
use App\Models\Client;
|
|
use App\Models\Sport;
|
|
use App\Models\User;
|
|
use Livewire\Component;
|
|
|
|
class SportSwitcher extends Component
|
|
{
|
|
public $sports = [];
|
|
|
|
public $sport_id = 0;
|
|
|
|
public $sporticon = '';
|
|
|
|
public $iconcolor = '';
|
|
|
|
protected $listeners = [
|
|
'refreshSportSwitcher' => '$refresh',
|
|
];
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
public function swopSport()
|
|
{
|
|
User::where('id', auth()->user()->id)->update(['sport_id' => $this->sport_id]);
|
|
|
|
$this->sporticon = Sport::where('id', $this->sport_id)->pluck('icon')->first();
|
|
|
|
$this->iconcolor = Sport::where('id', $this->sport_id)->pluck('color')->first();
|
|
|
|
$this->dispatch('filterClearFilter');
|
|
|
|
$this->js('window.location.reload()');
|
|
|
|
// $this->dispatch('refreshSportSwitcher');
|
|
|
|
// $this->dispatch('refreshBettypeMenu');
|
|
|
|
// $this->dispatch('refreshMultilineBookmaker');
|
|
|
|
// $this->dispatch('refreshComparingBookmakerMenu');
|
|
|
|
// $this->dispatch('refreshAlarmBookmaker');
|
|
|
|
}
|
|
|
|
public function render()
|
|
{
|
|
return view('livewire.sport-switcher');
|
|
}
|
|
}
|