grapper betsapi ok
This commit is contained in:
1 parent
b1a724061f
commit
34690292aa
15 files changed
+1751
-97
No files matched your search
@@ -4,12 +4,15 @@ namespace App\Livewire;
|
||||
|
||||
use App\Filament\Tables\Columns\MapperRightColumn;
|
||||
use App\Mapper\LoadProvider;
|
||||
use App\Mapper\StoreMapped;
|
||||
use App\Models\Country;
|
||||
use App\Models\Event;
|
||||
use App\Models\Mapper;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\Concerns\InteractsWithActions;
|
||||
use Filament\Actions\Contracts\HasActions;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Filament\Schemas\Concerns\InteractsWithSchemas;
|
||||
use Filament\Schemas\Contracts\HasSchemas;
|
||||
use Filament\Support\Enums\Alignment;
|
||||
@@ -19,6 +22,8 @@ use Filament\Tables\Enums\FiltersLayout;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Livewire\Component;
|
||||
|
||||
class MapperRight extends Component implements HasActions, HasSchemas, HasTable
|
||||
@@ -27,6 +32,8 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable
|
||||
use InteractsWithSchemas;
|
||||
use InteractsWithTable;
|
||||
|
||||
public $elements_swopped = false;
|
||||
|
||||
protected $listeners = [
|
||||
'reload_data' => '$refresh',
|
||||
];
|
||||
@@ -46,33 +53,45 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable
|
||||
->placeholder('Country')
|
||||
->hiddenLabel()
|
||||
->label('')
|
||||
->relationship('country_betsapi', 'name')
|
||||
->searchable()
|
||||
->preload()
|
||||
->multiple()
|
||||
->columnSpan(2)
|
||||
->live()
|
||||
->options(function () {
|
||||
$res = Mapper::query()->where('sport_id', Auth::user()->sport_id)->where('provider_id', Auth::user()->provider_id)->where('starttime', '>', Carbon::now())->groupBy('group_cc')->pluck('group_cc')->toArray();
|
||||
|
||||
return Country::query()->whereIn('iso2', $res)->pluck('name', 'iso2');
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('group_id', null);
|
||||
})
|
||||
->placeholder('Country')
|
||||
->label('Countries'),
|
||||
Select::make('group_id')
|
||||
->placeholder('League')
|
||||
->label('Leagues')
|
||||
->hiddenLabel()
|
||||
->label('')
|
||||
->options(fn () => Mapper::groupBy('group_id')->pluck('group', 'group_id'))
|
||||
->columnSpan(2)
|
||||
->searchable()
|
||||
->preload()
|
||||
->multiple()
|
||||
->live()
|
||||
->placeholder('League')
|
||||
->label('Leagues'),
|
||||
->options(function (Get $get) {
|
||||
if ($get('group_cc')) {
|
||||
return Mapper::query()->where('sport_id', Auth::user()->sport_id)->where('provider_id', Auth::user()->provider_id)->where('starttime', '>', Carbon::now())->whereIn('group_cc', $get('group_cc'))->groupBy('group_id')->pluck('group', 'group_id')->toArray();
|
||||
} else {
|
||||
return Mapper::query()->where('sport_id', Auth::user()->sport_id)->where('provider_id', Auth::user()->provider_id)->where('starttime', '>', Carbon::now())->groupBy('group_id')->pluck('group', 'group_id')->toArray();
|
||||
}
|
||||
})
|
||||
->live(),
|
||||
])
|
||||
->query(function (Builder $query, array $data): Builder {
|
||||
return $query
|
||||
->when(
|
||||
$data['group_cc'],
|
||||
fn (Builder $query, $group_cc) => $query->where('group_cc', $group_cc)
|
||||
fn (Builder $query, $group_cc) => $query->whereIn('group_cc', $group_cc)
|
||||
)->when(
|
||||
$data['group_id'],
|
||||
fn (Builder $query, $group_id) => $query->whereIn('group_id', $group_id)
|
||||
@@ -89,7 +108,6 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable
|
||||
->hiddenLabel()
|
||||
->color('gray')
|
||||
->icon('heroicon-o-arrow-path')
|
||||
// ->icon('phosphor-x')
|
||||
->action(function (Component $livewire) {
|
||||
$livewire->resetTableFiltersForm(); // Clears all filters
|
||||
$this->tableSearch = ''; // Clears the main search bar
|
||||
@@ -97,16 +115,28 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable
|
||||
]);
|
||||
}
|
||||
|
||||
public function toggle()
|
||||
{
|
||||
$this->elements_swopped = ! $this->elements_swopped;
|
||||
}
|
||||
|
||||
public function rightAction(): Action
|
||||
{
|
||||
return Action::make('right')
|
||||
->modalHeading('Event Mapper')
|
||||
->modalContent(function (array $arguments) {
|
||||
$event = Event::where('id', $arguments['match_id'])->first();
|
||||
|
||||
$event = Event::where('id', $arguments['id'])->first();
|
||||
|
||||
$mapper = Mapper::where('event_id', $arguments['event_id'])->first();
|
||||
|
||||
return view('livewire.confirm-mapping', ['event' => $event, 'mapper' => $mapper, 'mappermode' => 'linear']);
|
||||
return view('livewire.confirm-mapping', ['event' => $event, 'mapper' => $mapper]);
|
||||
})->action(function ($arguments) {
|
||||
StoreMapped::store($arguments, $this->elements_swopped);
|
||||
})
|
||||
->closeModalByEscaping(false)
|
||||
->modalCloseButton(false)
|
||||
->closeModalByClickingAway(false)
|
||||
->modalAlignment(Alignment::Center)
|
||||
->modalFooterActionsAlignment(Alignment::Center)
|
||||
->modalWidth('2xl')
|
||||
|
||||
Reference in new issue
Block a user