56 lines
1.3 KiB
PHP
56 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Livewire;
|
|
|
|
use App\Models\Provider;
|
|
use App\Models\Sport;
|
|
use App\Models\User;
|
|
use Illuminate\Support\Facades\Route;
|
|
use Livewire\Component;
|
|
|
|
class TopMenuItems extends Component
|
|
{
|
|
public $current = '';
|
|
|
|
protected $listeners = [
|
|
'refreshMapperLeft' => '$refresh',
|
|
'refreshMapperRight' => '$refresh',
|
|
];
|
|
|
|
protected string $sport = '';
|
|
|
|
public function mount()
|
|
{
|
|
$this->current = Route::currentRouteName();
|
|
|
|
}
|
|
|
|
public function setUser()
|
|
{
|
|
$user = User::find(auth()->user()->id);
|
|
|
|
$this->sport = Sport::where('id', $user->sport_id)->value('name');
|
|
}
|
|
|
|
public function render()
|
|
{
|
|
return view('livewire.top-menu-items', ['sport' => $this->sport]);
|
|
}
|
|
|
|
public function swopBookmaker($bookmaker_id)
|
|
{
|
|
$provider_id = Provider::where('bookmaker_id', $bookmaker_id)->value('id');
|
|
|
|
User::where('id', auth()->user()->id)->update(['provider_id' => $provider_id, 'bookmaker_id' => $bookmaker_id, 'partner_bookmaker_id' => auth()->user()->bookmaker_id]);
|
|
|
|
$this->js('window.location.reload()');
|
|
}
|
|
|
|
public function swopProvider($provider_id)
|
|
{
|
|
User::where('id', auth()->user()->id)->update(['provider_id' => $provider_id]);
|
|
|
|
$this->dispatch('refreshMapperRight');
|
|
}
|
|
}
|