This commit is contained in:
salam committed 2026-10-04 15:25:03 +02:00
1 parent 9bcd4432c6
commit 6f92f9e1d5
1209 files changed
+220940

No files matched your search

@@ -0,0 +1,176 @@
<?php
namespace App\Filament\Resources\Events;
use App\Filament\Resources\Events\Pages\ListEvents;
use App\Filament\Resources\Events\Schemas\EventForm;
use App\Filament\Resources\Events\Tables\EventsTable;
use App\Filament\Resources\Events\Tables\Tools\LoadClientStartimeDifference;
use App\Filament\Resources\Events\Tables\Tools\LoadPartnerDifferences;
use App\Models\Event;
use Carbon\Carbon;
use Filament\Resources\Resource;
use Filament\Schemas\Schema;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Facades\DB;
class EventResource extends Resource
{
protected static ?string $model = Event::class;
protected static string|\BackedEnum|null $navigationIcon = 'phosphor-monitor';
protected static ?int $navigationSort = 3;
protected static ?string $navigationLabel = 'Monitor';
protected static ?string $modelLabel = 'Monitor';
protected static ?string $title = 'Monitor';
public static function getPluralModelLabel(): string
{
return '';
}
public static function form(Schema $schema): Schema
{
return EventForm::configure($schema);
}
public static function table(Table $table): Table
{
return EventsTable::configure($table);
}
public static function getPages(): array
{
return [
'index' => ListEvents::route('/'),
];
}
// public static function getNavigationBadge(): ?string
// {
// return parent::getEloquentQuery()
// ->where('has_markets', 1)
// ->where('sport_id', auth()->user()->sport_id)
// ->where('starttime', '>=', Carbon::now())
// ->count();
// }
public static function getEloquentQuery(): Builder
{
$query = parent::getEloquentQuery()
->with('competition_group')
->with('country')
->with('home')
->with('away')
->with('home_betsapi')
->with('away_betsapi')
->with('event_bookmaker')
->with('event_user_star')
->with('event_user_note')
->where('has_markets', 1)
->where('sport_id', auth()->user()->sport_id)
->orderBy('starttime', 'ASC');
$query->where('starttime', '>=', Carbon::now());
// if (config('env.app_env') == 'production') {
// $query->where('starttime', '>=', Carbon::now()->subHour());
// } else {
// $query->where('starttime', '>=', Carbon::now());
// }
if (auth()->user()->all_only_none > 0) {
switch (auth()->user()->all_only_none) {
case 1:
$query->whereHas('event_bookmaker');
break;
case 2:
$query->doesntHave('event_bookmaker');
break;
}
}
if (auth()->user()->partner_compare) {
$event_ids = LoadPartnerDifferences::load();
$query->whereIn('id', $event_ids);
}
if (auth()->user()->starttime_differences) {
$event_ids = LoadClientStartimeDifference::load();
$query->whereIn('id', $event_ids);
}
if (auth()->user()->bookmaker_partner_differences == 1) {
// $a = EventBookmaker::where('bookmaker_id', auth()->user()->bookmaker_id)
// ->where('sport_id', auth()->user()->sport_id)
// ->pluck('event_id')->toArray();
// $b = EventBookmaker::where('bookmaker_id', auth()->user()->partner_bookmaker_id)
// ->where('sport_id', auth()->user()->sport_id)
// ->pluck('event_id')->toArray();
// $result = array_diff($a, $b);
// $query->whereIn('id', $result);
$e = DB::table('event_bookmakers')
->selectRaw('count(id) as c, event_id')
->whereIn('bookmaker_id', [auth()->user()->bookmaker_id, auth()->user()->partner_bookmaker_id])
->where('sport_id', auth()->user()->sport_id)
->where('starttime', '>', Carbon::now()->timezone('CET'))
->groupBy('event_id')
->havingRaw('c = 1')
->pluck('event_id')->toArray();
$query->whereIn('id', $e);
}
if (isset((EventsTable::$bettype_settings))) {
if (in_array('odds_2ways', EventsTable::$bettype_settings)) {
$query->with('odds_2ways.bookmaker');
}
if (in_array('odds_2ways_s1', EventsTable::$bettype_settings)) {
$query->with('odds_2ways_s1.bookmaker');
}
if (in_array('odds_3ways', EventsTable::$bettype_settings)) {
$query->with('odds_3ways.bookmaker');
}
if (in_array('odds_3ways_ht', EventsTable::$bettype_settings)) {
$query->with('odds_3ways_ht.bookmaker');
}
if (in_array('odds_dc', EventsTable::$bettype_settings)) {
$query->with('odds_dc.bookmaker');
}
if (in_array('odds_dnb', EventsTable::$bettype_settings)) {
$query->with('odds_dnb.bookmaker');
}
if (in_array('odds_ggng', EventsTable::$bettype_settings)) {
$query->with('odds_ggng.bookmaker');
}
if (in_array('odds_points', EventsTable::$bettype_settings)) {
$query->with('odds_points.bookmaker');
}
if (in_array('odds_points_ht', EventsTable::$bettype_settings)) {
$query->with('odds_points_ht.bookmaker');
}
if (in_array('odds_points_q1', EventsTable::$bettype_settings)) {
$query->with('odds_points_q1.bookmaker');
}
if (in_array('odds_totals', EventsTable::$bettype_settings)) {
$query->with('odds_totals.bookmaker');
}
if (in_array('odds_totals_ht', EventsTable::$bettype_settings)) {
$query->with('odds_totals_ht.bookmaker');
}
if (in_array('odds_totals_q1', EventsTable::$bettype_settings)) {
$query->with('odds_totals_q1.bookmaker');
}
if (in_array('odds_tq', EventsTable::$bettype_settings)) {
$query->with('odds_tq.bookmaker');
}
}
return $query;
}
}
@@ -0,0 +1,11 @@
<?php
namespace App\Filament\Resources\Events\Pages;
use App\Filament\Resources\Events\EventResource;
use Filament\Resources\Pages\CreateRecord;
class CreateEvent extends CreateRecord
{
protected static string $resource = EventResource::class;
}
@@ -0,0 +1,11 @@
<?php
namespace App\Filament\Resources\Events\Pages;
use App\Filament\Resources\Events\EventResource;
use Filament\Resources\Pages\EditRecord;
class EditEvent extends EditRecord
{
protected static string $resource = EventResource::class;
}
@@ -0,0 +1,100 @@
<?php
namespace App\Filament\Resources\Events\Pages;
use App\Filament\Resources\Events\EventResource;
use App\Filament\Resources\Events\Widgets\AlarmWidget;
use Filament\Resources\Pages\ListRecords;
use Filament\Support\Enums\Width;
class ListEvents extends ListRecords
{
protected static string $resource = EventResource::class;
protected string|Width|null $maxContentWidth = Width::Full;
protected $listeners = [
'refreshTable' => '$refresh',
'filterClearFilter' => 'clearFilters',
'filterUpdateGreen' => 'updateTableFiltersGreen',
'filterUpdateYellow' => 'updateTableFiltersYellow',
'filterUpdateRed' => 'updateTableFiltersRed',
'filterUpdatePeriode' => 'updateTablePeriode',
'filterStarFilter' => 'updateStar',
'filterNoteFilter' => 'updateNote',
];
protected function getHeaderWidgets(): array
{
return [
AlarmWidget::class,
];
}
public function clearFilters(): void
{
foreach ($this->tableFilters['events'] as $key => $value) {
$this->tableFilters['events'][$key] = null;
}
$this->removeTableFilters();
}
public function updateCompareDifferences(): void
{
$this->tableFilters['events']['bookmaker_partner_differences'] = ! $this->tableFilters['events']['bookmaker_partner_differences'];
}
public function updateStar(): void
{
$this->tableFilters['events']['filter_stars'] = ! $this->tableFilters['events']['filter_stars'];
}
public function updateNote(): void
{
$this->tableFilters['events']['filter_notes'] = ! $this->tableFilters['events']['filter_notes'];
}
public function updateNotification(): void
{
$this->tableFilters['events']['filter_notification'] = ! $this->tableFilters['events']['filter_notification'];
}
public function updateTablePeriode(string $filter): void
{
$filter = json_decode($filter, true);
$this->tableFilters['events']['starttime_period']['start'] = $filter['start'];
$this->tableFilters['events']['starttime_period']['end'] = $filter['end'];
}
public function updateTableFiltersGreen(string $filter): void
{
$this->clearFilters();
$this->tableFilters['events']['filter_alarm_yellow'] = null;
$this->tableFilters['events']['filter_alarm_red'] = null;
$this->tableFilters['events']['filter_alarm_green'] = $filter;
}
public function updateTableFiltersYellow(string $filter): void
{
$this->clearFilters();
$this->tableFilters['events']['filter_alarm_red'] = null;
$this->tableFilters['events']['filter_alarm_green'] = null;
$this->tableFilters['events']['filter_alarm_yellow'] = $filter;
}
public function updateTableFiltersRed(string $filter): void
{
$this->clearFilters();
$this->tableFilters['events']['filter_alarm_yellow'] = null;
$this->tableFilters['events']['filter_alarm_green'] = null;
$this->tableFilters['events']['filter_alarm_red'] = $filter;
}
public function getColumns(): int|array
{
return [
'md' => 4,
'xl' => 6,
];
}
}
@@ -0,0 +1,20 @@
<?php
namespace App\Filament\Resources\Events\Schemas;
use Filament\Forms\Components\TextInput;
use Filament\Schemas\Schema;
class EventForm
{
public static function configure(Schema $schema): Schema
{
return $schema
->components([
// TextInput::make('provider_id')
// ->numeric()
// ->default(0),
]);
}
}
@@ -0,0 +1,699 @@
<?php
namespace App\Filament\Resources\Events\Tables;
use App\Filament\Resources\Events\Tables\Tools\CompareOptions;
use App\Filament\Resources\Events\Tables\Tools\LoadBettypeSettings;
use App\Filament\Resources\Events\Tables\Tools\LoadCompareDifferences;
use App\Filament\Resources\Events\Tables\Tools\LoadMultiline;
use App\Filament\Tables\Columns\ColumnOdds;
use App\Filament\Tables\Columns\ColumnStarttime;
use App\Filament\Tables\Columns\EventColumn;
use App\Filament\Tables\Columns\MatchIds;
use App\Filament\Tables\Columns\TooltipOdds;
use App\Models\ClientGroupList;
use App\Models\CompetitionGroup;
use App\Models\Country;
use App\Models\Event;
use App\Models\EventBookmaker;
use App\Models\EventUserNote;
use App\Models\EventUserStar;
use App\Models\Group;
use App\Models\OddsTable;
use CodeWithKyrian\FilamentDateRange\Forms\Components\DateRangePicker;
use Filament\Actions\Action;
use Filament\Actions\ActionGroup;
use Filament\Actions\DeleteAction;
use Filament\Forms\Components\Hidden;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\TextInput;
use Filament\Schemas\Components\Utilities\Get;
use Filament\Support\Enums\VerticalAlignment;
use Filament\Support\Enums\Width;
use Filament\Tables\Columns\IconColumn;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Enums\FiltersLayout;
use Filament\Tables\Filters\Filter;
use Filament\Tables\Filters\Indicator;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\DB;
class EventsTable
{
public static array $user;
public static array $bettype_settings;
public static array $slots;
public static array $bookmaker;
public static array $filter;
public static function configure(Table $table): Table
{
LoadMultiline::load();
LoadBettypeSettings::load();
return $table
->striped()
->poll('15s')
->deferLoading()
->defaultPaginationPageOption(5)
->extremePaginationLinks()
->paginated([5, 10, 15])
->columns([
IconColumn::make('sport.icon')
->label('')
->icon(fn($record) => $record->sport->icon)
->tooltip(fn($record) => $record->id)
->visibleFrom('lg'),
MatchIds::make('ids')->grow(false)->visibleFrom('xl')
->visible(fn() => auth()->user()->hasRole('super_admin')),
ColumnStarttime::make('start'),
TextColumn::make('country.name')
->label('League')
->wrap()
->hidden(fn() => auth()->user()->sport_id == 5)
->color('gray')
->icon(fn($record) => $record->country?->icon)
->description(fn($record) => ucwords($record->group?->name)),
EventColumn::make('event'),
TooltipOdds::make('ml')->bettype('odds_2ways')->label('')->visible(fn() => in_array('odds_2ways', self::$bettype_settings)),
ColumnOdds::make('odds_2ways')->bettype('odds_2ways')
->visible(fn() => in_array('odds_2ways', self::$bettype_settings))
->verticalAlignment(VerticalAlignment::Start)
->label('ML'),
TooltipOdds::make('mls1')->bettype('odds_2ways_s1')->label('')->visible(fn() => in_array('odds_2ways_s1', self::$bettype_settings)),
ColumnOdds::make('odds_2ways_s1')->bettype('odds_2ways_s1')
->visible(fn() => in_array('odds_2ways_s1', self::$bettype_settings))
->verticalAlignment(VerticalAlignment::Start)
->label('ML S1'),
TooltipOdds::make('1x2')->bettype('odds_3ways')->label('')->visible(fn() => in_array('odds_3ways', self::$bettype_settings)),
ColumnOdds::make('odds_3ways')
->bettype('odds_3ways')
->visible(fn() => in_array('odds_3ways', self::$bettype_settings))
->verticalAlignment(VerticalAlignment::Start)
->label('1X2'),
TooltipOdds::make('1x2ht')->bettype('odds_3ways_ht')->label('')->visible(fn() => in_array('odds_3ways_ht', self::$bettype_settings)),
ColumnOdds::make('odds_3ways_ht')->bettype('odds_3ways_ht')
->visible(fn() => in_array('odds_3ways_ht', self::$bettype_settings))
->verticalAlignment(VerticalAlignment::Start)
->label('1X2 HT'),
TooltipOdds::make('total')->bettype('odds_totals')->label('')->visible(fn() => in_array('odds_totals', self::$bettype_settings)),
ColumnOdds::make('odds_totals')->bettype('odds_totals')
->visible(fn() => in_array('odds_totals', self::$bettype_settings))
->verticalAlignment(VerticalAlignment::Start)
->label('Totals'),
TooltipOdds::make('total_ht')->bettype('odds_totals_ht')->label('')->visible(fn() => in_array('odds_totals_ht', self::$bettype_settings)),
ColumnOdds::make('odds_totals_ht')->bettype('odds_totals_ht')
->visible(fn() => in_array('odds_totals_ht', self::$bettype_settings))
->verticalAlignment(VerticalAlignment::Start)
->label('Totals HT'),
TooltipOdds::make('total_q1')->bettype('odds_totals_q1')->label('')->visible(fn() => in_array('odds_totals_q1', self::$bettype_settings)),
ColumnOdds::make('odds_totals_q1')->bettype('odds_totals_q1')
->visible(fn() => in_array('odds_totals_q1', self::$bettype_settings))
->verticalAlignment(VerticalAlignment::Start)
->alignCenter()
->label('Totals Q1'),
TooltipOdds::make('points')->bettype('odds_points')->label('')->visible(fn() => in_array('odds_points', self::$bettype_settings)),
ColumnOdds::make('odds_points')->bettype('odds_points')
->visible(fn() => in_array('odds_points', self::$bettype_settings))
->verticalAlignment(VerticalAlignment::Start)
->label('Points'),
TooltipOdds::make('points_ht')->bettype('odds_points_ht')->label('')->visible(fn() => in_array('odds_points_ht', self::$bettype_settings)),
ColumnOdds::make('odds_points_ht')->bettype('odds_points_ht')
->visible(fn() => in_array('odds_points_ht', self::$bettype_settings))
->verticalAlignment(VerticalAlignment::Start)
->label('Points HT'),
TooltipOdds::make('points_q1')->bettype('odds_points_q1')->label('')->visible(fn() => in_array('odds_points_q1', self::$bettype_settings)),
ColumnOdds::make('odds_points_q1')->bettype('odds_points_q1')
->visible(fn() => in_array('odds_points_q1', self::$bettype_settings))
->verticalAlignment(VerticalAlignment::Start)
->label('Points Q1'),
TooltipOdds::make('ggng')->bettype('odds_ggng')->label('')->visible(fn() => in_array('odds_ggng', self::$bettype_settings)),
ColumnOdds::make('odds_ggng')->bettype('odds_ggng')
->visible(fn() => \in_array('odds_ggng', self::$bettype_settings))
->verticalAlignment(VerticalAlignment::Start)
->label('Goal No Goal'),
TooltipOdds::make('dc')->bettype('odds_dc')->label('')->visible(fn() => in_array('odds_dc', self::$bettype_settings)),
ColumnOdds::make('odds_dc')->bettype('odds_dc')
->visible(fn() => \in_array('odds_dc', self::$bettype_settings))
->verticalAlignment(VerticalAlignment::Start)
->label('Double Chance'),
TooltipOdds::make('tq')->bettype('odds_tq')->label('')->visible(fn() => in_array('odds_tq', self::$bettype_settings)),
ColumnOdds::make('odds_tq')->bettype('odds_tq')
->visible(fn() => \in_array('odds_tq', self::$bettype_settings))
->verticalAlignment(VerticalAlignment::Start)
->label('To Qualify'),
TooltipOdds::make('dnb')->bettype('odds_dnb')->label('')->visible(fn() => in_array('odds_dnb', self::$bettype_settings)),
ColumnOdds::make('odds_dnb')->bettype('odds_dnb')
->visible(fn() => \in_array('odds_dnb', self::$bettype_settings))
->verticalAlignment(VerticalAlignment::Start)
->label('Draw No Bet'),
])
->searchable(['id', 'home.name', 'away.name', 'betsapi_id', 'betradar_id', 'bet365_id', 'bwin_id', 'event_bookmaker.event_id'])
->extremePaginationLinks()
->filters([
Filter::make('events')
->columns(7)->columnSpan(7)
->schema([
Hidden::make('filter_alarm_green'),
Hidden::make('filter_alarm_yellow'),
Hidden::make('filter_alarm_red'),
Hidden::make('filter_stars'),
Hidden::make('filter_notes'),
Hidden::make('filter_periode'),
Select::make('country_id')
->placeholder('Country')
->prefixIcon('phosphor-flag')
->hiddenLabel()
->label('')
->multiple()
->searchable()
->preload()
->options(function () {
$res = Event::where('has_markets', 1)
->where('sport_id', auth()->user()->sport_id)
->where('starttime', '>=', Carbon::now())
->groupBy('country_id')
->pluck('country_id')->toArray();
return Country::query()->whereIn('id', $res)->orderBy('name')->pluck('name', 'id');
})
->live()
->reactive()
->afterStateUpdated(function (callable $set) {
$set('competition_group_id', null);
}),
Select::make('client_group_list_id')
->placeholder('Custom Groups')
->prefixIcon('phosphor-user-list')
->searchable()
->hiddenLabel()
->label('')
->preload()
->options(fn() => ClientGroupList::where('sport_id', auth()->user()->sport_id)
->where('client_id', auth()->user()->client_id)
->pluck('name', 'id'))
->live(),
Select::make('competition_group_id')
->placeholder('League')
->prefixIcon('phosphor-trophy')
->hiddenLabel()
->label('')
->multiple()
->searchable()
->options(function (Get $get) {
if ($get('client_group_list_id')) {
$list = ClientGroupList::where('id', $get('client_group_list_id'))->value('client_groups');
$res = Event::where('has_markets', 1)
->with('country')
->with('competition_group')
->where('sport_id', auth()->user()->sport_id)
->where('starttime', '>', Carbon::now())
->whereIn('competition_group_id', $list)
->get();
} elseif ($get('country_id')) {
$res = Event::where('has_markets', 1)
->with('country')
->with('competition_group')
->where('sport_id', auth()->user()->sport_id)
->where('starttime', '>', Carbon::now())
->whereIn('country_id', $get('country_id'))
->get();
} else {
$res = Event::where('has_markets', 1)
->with('country')
->with('competition_group')
->where('sport_id', auth()->user()->sport_id)
->where('starttime', '>', Carbon::now())
->get();
}
$arr = [];
foreach ($res as $val) {
$arr[$val->competition_group_id] = $val->country?->name . ' ' . $val->competition_group?->name;
}
asort($arr);
return $arr;
})
->live(),
Select::make('competition_group_id')
->visible(fn() => auth()->user()->sport_id == 5)
->placeholder('Tournament')
->prefixIcon('phosphor-trophy')
->columnSpan(2)
->hiddenLabel()
->label('')
->multiple()
->searchable()
->options(function () {
$res = Event::where('has_markets', 1)
->with('competition_group')
->where('sport_id', auth()->user()->sport_id)
->where('starttime', '>', Carbon::now())
// ->groupBy('competition_group_id')
->get();
$arr = [];
foreach ($res as $val) {
if (! isset($arr[$val->competition_group_id])) {
$arr[$val->competition_group_id] = $val->competition_group->name;
}
}
asort($arr);
return $arr;
})
->live(),
DateRangePicker::make('starttime_period')
->columnSpan(2)
->displayFormat('d M Y')
->minDate(now())
->hiddenLabel()
->label('')
->live(),
TextInput::make('favorit_threshold')
->prefixIcon('phosphor-less-than')
->hintIconTooltip('Filter Favorit')
->suffix('Favorit')
->numeric()
->minValue(1.01)
->maxValue(3.00)
->step(0.01)
->hiddenLabel()
->live(),
Select::make('filter_compare_differences')
->placeholder('Compare')
->prefixIcon('phosphor-funnel')
->hiddenLabel()
->allowHtml()
->options(fn() => CompareOptions::load()),
])
->query(function (Builder $query, array $data): Builder {
return $query->when(
$data['country_id'],
function (Builder $query, $country_id) {
$query->whereIn('country_id', $country_id);
}
)->when(
$data['competition_group_id'],
fn(Builder $query, $competition_group_id) => $query->whereIn('competition_group_id', $competition_group_id)
)->when(
$data['client_group_list_id'],
function (Builder $query, $client_group_list_id) {
$client_group_list_ids = ClientGroupList::where('id', $client_group_list_id)->value('client_groups');
$query->whereIn('competition_group_id', $client_group_list_ids);
}
)->when(
$data['starttime_period'],
function (Builder $query, $starttime_period) {
// dd($starttime_period);
if (isset($starttime_period['start']) && isset($starttime_period['end'])) {
$from = Carbon::createFromDate($starttime_period['start']);
$end = Carbon::createFromDate($starttime_period['end']);
return $query
->where('starttime', '>=', $from)
->where('starttime', '<=', $end);
} elseif (isset($starttime_period['start'])) {
$from = Carbon::createFromDate($starttime_period['start']);
return $query
->where('starttime', '>=', $from);
} elseif (isset($starttime_period['end'])) {
$end = Carbon::createFromDate($starttime_period['end']);
return $query
->where('starttime', '<=', $end);
}
}
)->when(
$data['filter_alarm_green'],
function (Builder $query, $filter_alarm_green) {
$res = OddsTable::where('name', $filter_alarm_green)->value('fieldnames');
$fieldnames = explode(',', $res);
return $query->whereHas('event_bookmaker', function ($query) use ($fieldnames) {
$query->where('bookmaker_id', auth()->user()->bookmaker_id)
->where(function ($query) use ($fieldnames) {
foreach ($fieldnames as $field) {
$query->orWhere($field, 1);
}
});
});
}
)->when(
$data['filter_alarm_yellow'],
function (Builder $query, $filter_alarm_yellow) {
$res = OddsTable::where('name', $filter_alarm_yellow)->value('fieldnames');
$fieldnames = explode(',', $res);
return $query->whereHas('event_bookmaker', function ($query) use ($fieldnames) {
$query->where('bookmaker_id', auth()->user()->bookmaker_id)
->where(function ($query) use ($fieldnames) {
foreach ($fieldnames as $field) {
$query->orWhere($field, 2);
}
});
});
}
)->when(
$data['filter_alarm_red'],
function (Builder $query, $filter_alarm_red) {
$res = OddsTable::where('name', $filter_alarm_red)->value('fieldnames');
$fieldnames = explode(',', $res);
return $query->whereHas('event_bookmaker', function ($query) use ($fieldnames) {
$query->where('bookmaker_id', auth()->user()->bookmaker_id)
->where(function ($query) use ($fieldnames) {
foreach ($fieldnames as $field) {
$query->orWhere($field, 3);
}
});
});
}
)->when(
$data['filter_compare_differences'],
function (Builder $query, $filter_compare_differences) {
$opt = explode('-', $filter_compare_differences);
$compare_bookmaker_id = (int) $opt[2];
switch (auth()->user()->sport_id) {
case 1:
case 2:
$event_ids = LoadCompareDifferences::load($opt[0], $opt[1], 'odds_3ways', $compare_bookmaker_id);
break;
case 3:
$event_ids = LoadCompareDifferences::load($opt[0], $opt[1], 'odds_points', $compare_bookmaker_id);
break;
case 5:
$event_ids = LoadCompareDifferences::load($opt[0], $opt[1], 'odds_2ways', $compare_bookmaker_id);
break;
}
$query->whereIn('id', $event_ids);
}
)->when(
$data['filter_stars'],
function (Builder $query, $filter_stars) {
$query->whereHas('event_user_star');
}
)->when(
in_array('odds_tq', self::$bettype_settings),
function (Builder $query, $filter_stars) {
$query->whereHas('odds_tq');
}
)->when(
$data['filter_notes'],
function (Builder $query, $filter_notes) {
$query->whereHas('event_user_note');
}
)->when(
$data['favorit_threshold'],
function (Builder $query, $favorit_threshold) {
switch (auth()->user()->sport_id) {
case 1:
return $query->whereHas('odds_3ways', function ($query) use ($favorit_threshold) {
$query->where('bookmaker_id', auth()->user()->bookmaker_id)->whereRaw('LEAST(h3w, d3w, a3w) BETWEEN ? AND ?', [1, $favorit_threshold]);
});
break;
case 2:
return $query->whereHas('odds_3ways', function ($query) use ($favorit_threshold) {
$query->where('bookmaker_id', auth()->user()->bookmaker_id)->whereRaw('LEAST(h3w, d3w, a3w) BETWEEN ? AND ?', [1, $favorit_threshold]);
});
break;
case 3:
return $query->whereHas('odds_points', function ($query) use ($favorit_threshold) {
$query->where('bookmaker_id', auth()->user()->bookmaker_id)->where('active_spread', 1)->whereRaw('LEAST(home, away) BETWEEN ? AND ?', [1, $favorit_threshold]);
});
break;
case 5:
return $query->whereHas('odds_2ways', function ($query) use ($favorit_threshold) {
$query->where('bookmaker_id', auth()->user()->bookmaker_id)->whereRaw('LEAST(h2w, a2w) BETWEEN ? AND ?', [1, $favorit_threshold]);
});
break;
}
}
);
})->indicateUsing(function (array $data): array {
$indicators = [];
if ($data['country_id'] ?? null) {
$countries = Country::whereIn('id', $data['country_id'])->pluck('name')->toArray();
if (count($countries) > 1) {
$indicators[] = Indicator::make(implode(', ', $countries))->removeField('country_id')->color('info');
} else {
$indicators[] = Indicator::make($countries[0])->removeField('country_id')->color('info');
}
}
if ($data['group_id'] ?? null) {
$group_ids = Group::whereIn('id', $data['group_id'])->pluck('name')->toArray();
if (count($group_ids) > 1) {
$indicators[] = Indicator::make(implode(', ', $group_ids))->removeField('group_id')->color('info');
} else {
$indicators[] = Indicator::make($group_ids[0])->removeField('group_id')->color('info');
}
}
if ($data['client_group_list_id'] ?? null) {
$client_group_list_name = ClientGroupList::where('id', $data['client_group_list_id'])->value('name');
$indicators[] = Indicator::make('Custom Group: ' . $client_group_list_name)->removeField('client_group_list_id')->color('info');
}
if ($data['filter_stars'] ?? null) {
$indicators[] = Indicator::make('Favorits')->removeField('filter_stars')->color('info');
}
if (in_array('odds_tq', self::$bettype_settings)) {
$indicators[] = Indicator::make('To Qualify')->color('info')->removable(false);
}
if ($data['filter_notes'] ?? null) {
$indicators[] = Indicator::make('Notes')->removeField('filter_notes')->color('info');
}
if ($data['filter_alarm_green'] ?? null) {
$title = OddsTable::where('name', $data['filter_alarm_green'])->value('title');
$indicators[] = Indicator::make('Alarms: ' . $title)->removeField('filter_alarm_green')->color('success');
}
if ($data['filter_alarm_yellow'] ?? null) {
$title = OddsTable::where('name', $data['filter_alarm_yellow'])->value('title');
$indicators[] = Indicator::make('Alarms: ' . $title)->removeField('filter_alarm_yellow')->color('info');
}
if ($data['filter_alarm_red'] ?? null) {
$title = OddsTable::where('name', $data['filter_alarm_red'])->value('title');
$indicators[] = Indicator::make('Alarms: ' . $title)->removeField('filter_alarm_red')->color('danger');
}
if ($data['starttime_period'] ?? null) {
$span = $data['starttime_period'];
$text = '';
if ($span['start'] ?? null) {
$text .= Carbon::parse($span['start'])->format('d. M.');
}
if ($span['end'] ?? null) {
$text .= ' - ' . Carbon::parse($span['end'])->format('d. M.');
}
if ($text) {
$indicators[] = Indicator::make($text)->removeField('starttime_period.start')->color('info');
}
}
if ($data['competition_group_id'] ?? null) {
$competition_groups = CompetitionGroup::whereIn('id', $data['competition_group_id'])->pluck('name')->toArray();
if (count($competition_groups) > 1) {
$indicators[] = Indicator::make(implode(', ', $competition_groups))->removeField('competition_group_id')->color('info');
} else {
$indicators[] = Indicator::make($competition_groups[0])->removeField('competition_group_id')->color('info')->color('info');
}
}
if ($data['favorit_threshold'] ?? null) {
switch (auth()->user()->sport_id) {
case 1:
$indicators[] = Indicator::make('1X2 Fav <= ' . $data['favorit_threshold'])->removeField('favorit_threshold')->color('warning');
break;
case 2:
$indicators[] = Indicator::make('1X2 Fav <= ' . $data['favorit_threshold'])->removeField('favorit_threshold')->color('warning');
break;
case 3:
$indicators[] = Indicator::make('HC Fav <= ' . $data['favorit_threshold'])->removeField('favorit_threshold')->color('warning');
break;
case 5:
$indicators[] = Indicator::make('ML Fav <= ' . $data['favorit_threshold'])->removeField('favorit_threshold')->color('warning');
break;
}
}
if ($data['filter_compare_differences'] ?? null) {
$opt = explode('-', $data['filter_compare_differences']);
$title = $opt[0];
switch ($opt[1]) {
case 'lte':
$title .= ' ≤ ';
break;
case 'gte':
$title .= ' ≥ ';
break;
case 'lt':
$title .= ' > ';
break;
}
$title .= $opt[3];
$indicators[] = Indicator::make($title)->removeField('filter_compare_differences')->color('warning');
}
return $indicators;
}),
], layout: FiltersLayout::AboveContent)
->deferFilters(false)
->hiddenFilterIndicators(false)
->persistFiltersInSession()
->emptyStateHeading('No events')
->emptyStateDescription('Modify the filter')
->recordUrl(null) // disable row click for page
->recordAction(null) // disable row click for modal
->recordActions([
// Action::make('event-statistic')
// ->iconButton()
// ->modalIcon('phosphor-chart-line')
// ->color('gray')
// ->modalHeading(fn ($record) => $record->country->name.' - '.$record->group->name)
// ->icon('phosphor-chart-line')
// ->modalContent(fn ($record): View => view(
// 'statistic-event-chart',
// ['record' => $record],
// )),
Action::make('star')
->iconButton()
->color(function ($record) {
if (isset($record->event_user_star->id)) {
return 'info';
} else {
return 'gray';
}
})
->icon(function ($record) {
if (isset($record->event_user_star->id)) {
return 'phosphor-star-fill';
} else {
return 'phosphor-star-duotone';
}
})
->tooltip('Add to favorits')
->action(function ($record) {
$res = EventUserStar::where('event_id', $record->id)
->where('user_id', auth()->user()->id)
->first();
if ($res) {
EventUserStar::find($res->id)->delete();
} else {
EventUserStar::insert(['event_id' => $record->id, 'user_id' => auth()->user()->id]);
}
}),
Action::make('event_note')
->modalIcon('phosphor-note-pencil-duotone')
->modalWidth(Width::Large)
->modalSubmitActionLabel('Save')
->extraModalFooterActions(fn(Action $action, $record) => $record->event_user_note->isEmpty() ? [] : [$action->makeModalSubmitAction('Delete', arguments: ['delete' => true])->color('danger')])
->fillForm(data: function ($record) {
foreach ($record->event_user_note as $value) {
if ($value->user_id == auth()->user()->id && $value->bookmaker_id == auth()->user()->bookmaker_id) {
return [
'event_user_note_id' => $value->id,
'message' => $value->message,
];
}
}
return ['event_user_note_id' => ''];
})
->schema([
Hidden::make('event_user_note_id'),
Textarea::make('message')
->rows(2)
->hiddenLabel(),
])
->icon('phosphor-note-pencil-duotone')
->iconButton()
->tooltip(fn($record) => view('filament.resources.events.tooltip.event-user-note-tooltip', ['notes' => $record->event_user_note]))
->action(function ($record, array $data, $arguments = []) {
if ($arguments) {
EventUserNote::where('id', $data['event_user_note_id'])->delete();
} elseif ($data['event_user_note_id']) {
if (! $data['message']) {
EventUserNote::where('id', $data['event_user_note_id'])->delete();
} else {
EventUserNote::where('id', $data['event_user_note_id'])->update(['message' => $data['message']]);
}
} else {
EventUserNote::updateOrCreate([
'event_id' => $record->id,
'user_id' => auth()->user()->id,
'client_id' => auth()->user()->client_id,
'bookmaker_id' => auth()->user()->bookmaker_id,
], [
'message' => $data['message'],
]);
}
})
->color(fn($record) => $record->event_user_note->isEmpty() ? 'gray' : 'info'),
ActionGroup::make([
DeleteAction::make()->visible(fn() => auth()->user()->hasRole('super_admin')),
Action::make('txodds_odds')
->label('TxOdds')
->disabled(fn() => ! auth()->user()->hasRole('super_admin'))
->icon('phosphor-arrow-square-out')
->url(fn($record): string => route('txodds_odds', ['sportid' => $record->sport_id, 'txoddsid' => $record->id]))
->openUrlInNewTab(),
Action::make('swap_elements')
->icon('phosphor-swap')
->action(function ($record, $livewire) {
EventBookmaker::where('event_id', $record->id)->where('bookmaker_id', auth()->user()->bookmaker_id)->update(['is_swopped' => DB::raw('!is_swopped')]);
$livewire->dispatch('refreshBettypeMenu');
}),
])->iconButton()
->icon('phosphor-dots-three-vertical'),
]);
}
}
@@ -0,0 +1,73 @@
<?php
namespace App\Filament\Resources\Events\Tables\Tools;
use App\Filament\Resources\Events\Tables\EventsTable;
use App\Models\Bookmaker;
class CompareOptions
{
public static function load()
{
$map = Bookmaker::map();
$favorits = [];
$margins = [];
$x = [];
switch (auth()->user()->sport_id) {
case 1:
case 2:
$table = 'odds_3ways';
break;
case 3:
$table = 'odds_points';
break;
case 5:
$table = 'odds_2ways';
break;
}
$options = [];
foreach (EventsTable::$slots[$table] as $bookmaker_id) {
if (isset($map[$bookmaker_id])) {
$option = 'Favorit-lte-'.$bookmaker_id.'-'.$map[$bookmaker_id]['name'];
$favorits[$option] = 'Favorit ≤ '.$map[$bookmaker_id]['name'];
}
}
foreach (EventsTable::$slots[$table] as $bookmaker_id) {
if (isset($map[$bookmaker_id])) {
$option = 'Favorit-gte-'.$bookmaker_id.'-'.$map[$bookmaker_id]['name'];
$favorits[$option] = 'Favorit ≥ '.$map[$bookmaker_id]['name'];
}
}
$options['Favorits'] = $favorits;
foreach (EventsTable::$slots[$table] as $bookmaker_id) {
if (isset($map[$bookmaker_id])) {
$option = 'Margin-gte-'.$bookmaker_id.'-'.$map[$bookmaker_id]['name'];
$margins[$option] = 'Margin ≥ '.$map[$bookmaker_id]['name'];
}
}
foreach (EventsTable::$slots[$table] as $bookmaker_id) {
if (isset($map[$bookmaker_id])) {
$option = 'Margin-lt-'.$bookmaker_id.'-'.$map[$bookmaker_id]['name'];
$margins[$option] = 'Margin < '.$map[$bookmaker_id]['name'];
}
}
$options['Margins'] = $margins;
if (auth()->user()->sport_id == 1) {
foreach (EventsTable::$slots[$table] as $bookmaker_id) {
if (isset($map[$bookmaker_id])) {
$option = 'X-lt-'.$bookmaker_id.'-'.$map[$bookmaker_id]['name'];
$x[$option] = 'X < '.$map[$bookmaker_id]['name'];
}
}
$options['X'] = $x;
}
return $options;
}
}
@@ -0,0 +1,25 @@
<?php
namespace App\Filament\Resources\Events\Tables\Tools;
use App\Filament\Resources\Events\Tables\EventsTable;
use App\Models\BettypeUser;
class LoadBettypeSettings
{
public static function load()
{
$res = BettypeUser::with('multiline_setting')
->where('user_id', auth()->user()->id)
->where('sport_id', auth()->user()->sport_id)
->where('is_active', 1)
->orderBy('sorting')
->get();
$arr = [];
foreach ($res as $value) {
$arr[] = $value->multiline_setting->table;
}
EventsTable::$bettype_settings = $arr;
}
}
@@ -0,0 +1,30 @@
<?php
namespace App\Filament\Resources\Events\Tables\Tools;
use App\Models\Event;
use Illuminate\Support\Carbon;
class LoadClientStartimeDifference
{
public static function load()
{
$events = Event::with('event_bookmaker')
->where('sport_id', auth()->user()->sport_id)
->where('starttime', '>=', Carbon::now())
->whereHas('event_bookmaker', function ($query) {
$query->where('bookmaker_id', auth()->user()->bookmaker_id);
})
->get();
$event_ids = [];
foreach ($events as $event) {
if ($event->starttime != $event->event_bookmaker->starttime) {
$event_ids[] = $event->id;
}
}
return array_unique($event_ids);
}
}
@@ -0,0 +1,107 @@
<?php
namespace App\Filament\Resources\Events\Tables\Tools;
use App\Models\OddsTable;
use Illuminate\Support\Facades\DB;
class LoadCompareDifferences
{
public static function load($target, $mode, $table, $compare_bookmaker_id)
{
$fields = OddsTable::fields();
// dd($target, $mode, $table, $compare_bookmaker_id);
// echo $table."\n";
// dd(auth()->user()->sport_id);
$has_active_spread = OddsTable::where('name', $table)->value('has_active_spread');
if ($has_active_spread) {
$clients = DB::table($table)
->where('bookmaker_id', auth()->user()->bookmaker_id)
->where('active_spread', 1)
->get();
$comparing = DB::table($table)
->where('bookmaker_id', $compare_bookmaker_id)
->where('active_spread', 1)
->get();
} else {
// $clients = DB::table($table)->whereIn('bookmaker_id', [auth()->user()->bookmaker_id, $compare_bookmaker_id])->get();
$clients = DB::table($table)
->where('bookmaker_id', auth()->user()->bookmaker_id)
->get();
$comparing = DB::table($table)
->where('bookmaker_id', $compare_bookmaker_id)
->get();
}
$event_ids = [];
foreach ($clients as $client) {
$row1 = get_object_vars($client);
foreach ($comparing as $compare) {
$row2 = get_object_vars($compare);
if ($row1['event_id'] == $row2['event_id']) {
switch ($target) {
case 'Favorit':
$bk = 100;
$co = 100;
foreach ($fields[$table] as $field) {
if ($row1[$field] < $bk) {
$bk = $row1[$field];
}
if ($row2[$field] < $co) {
$co = $row2[$field];
}
}
switch ($mode) {
case 'lte':
if ($bk > 1 && $co > 1 && $bk <= $co) {
$event_ids[] = $row1['event_id'];
}
break;
case 'gte':
if ($bk > 1 && $co > 1 && $bk >= $co) {
$event_ids[] = $row1['event_id'];
}
break;
}
break;
case 'Margin':
switch ($mode) {
case 'gte':
if ($row1['margin'] >= $row2['margin']) {
$event_ids[] = $row1['event_id'];
}
break;
case 'lt':
if ($row1['margin'] < $row2['margin']) {
$event_ids[] = $row1['event_id'];
}
break;
}
break;
case 'X':
if ($row1['d3w'] < $row2['d3w']) {
$event_ids[] = $row1['event_id'];
}
break;
}
}
}
}
return array_unique($event_ids);
}
}
@@ -0,0 +1,51 @@
<?php
namespace App\Filament\Resources\Events\Tables\Tools;
use App\Filament\Resources\Events\Tables\EventsTable;
use App\Models\ComparingBookmaker;
use App\Models\MultilineClient;
use App\Models\MultilineSetting;
class LoadMultiline
{
public static function load()
{
$cb = ComparingBookmaker::where('sport_id', auth()->user()->sport_id)
->where('client_bookmaker_id', auth()->user()->bookmaker_id)
->orderBy('sorting', 'desc')
->select('bookmaker_id', 'time_lastcheck', 'margin_threshold', 'is_active')
->get();
$bookmakers = [];
$filter = [];
foreach ($cb as $value) {
if (auth()->user()->bookmaker_id != $value->bookmaker_id) {
$bookmakers[] = $value->bookmaker_id;
$filter[$value->bookmaker_id] = [
'time_lastcheck' => $value->time_lastcheck,
'margin' => $value->margin_threshold,
];
}
}
$res = MultilineSetting::where('sport_id', auth()->user()->sport_id)->get();
foreach ($res as $value) {
EventsTable::$filter[$value->table] = $filter;
EventsTable::$bookmaker[$value->table] = $bookmakers;
}
$res = MultilineClient::with('multiline_setting')
->where('sport_id', auth()->user()->sport_id)
->where('client_bookmaker_id', auth()->user()->bookmaker_id)
->select('bookmaker_id', 'multiline_setting_id')
->orderBy('sort')
->get();
foreach ($res as $value) {
$table = $value->multiline_setting->table;
EventsTable::$slots[$table][] = (int) $value->bookmaker_id;
}
}
}
@@ -0,0 +1,47 @@
<?php
namespace App\Filament\Resources\Events\Tables\Tools;
use App\Filament\Resources\Events\Tables\EventsTable;
use App\Models\OddsTable;
use Illuminate\Support\Facades\DB;
class LoadPartnerDifferences
{
public static function load()
{
$event_ids = [];
foreach (EventsTable::$bettype_settings as $table) {
$has_active_spread = OddsTable::where('name', $table)->value('has_active_spread');
if ($has_active_spread) {
$events = DB::table($table)
->whereIn('bookmaker_id', [auth()->user()->bookmaker_id, auth()->user()->partner_bookmaker_id])
->where('active_spread', 1)
->get();
} else {
$events = DB::table($table)
->whereIn('bookmaker_id', [auth()->user()->bookmaker_id, auth()->user()->partner_bookmaker_id])
->get();
}
$res = [];
foreach ($events as $value) {
$value = get_object_vars($value);
$event_id = $value['event_id'];
foreach (['id', 'event_id', 'sport_id', 'bookmaker_id', 'provider_id', 'offer_id', 'bmoid', 'margin', 'flags', 'nuh_check', 'last_updated', 'created_at', 'updated_at'] as $fieldname) {
unset($value[$fieldname]);
}
$res[$event_id][] = $value;
}
foreach ($res as $event_id => $odds) {
if (count($odds) == 2 && array_diff($odds[0], $odds[1])) {
$event_ids[] = $event_id;
}
}
}
return array_unique($event_ids);
}
}
@@ -0,0 +1,122 @@
<?php
namespace App\Filament\Resources\Events\Widgets;
use App\Actions\AlarmStatistic;
use Filament\Widgets\Concerns\InteractsWithPageFilters;
use Filament\Widgets\StatsOverviewWidget;
use Filament\Widgets\StatsOverviewWidget\Stat;
class AlarmWidget extends StatsOverviewWidget
{
use InteractsWithPageFilters;
protected $listeners = [
'refreshAlarmWidget' => '$refresh',
];
protected ?string $pollingInterval = '15s';
public array $filters = [];
protected function getStats(): array
{
// if (auth()->user()->partner_show) {
// return [];
// }
$res = AlarmStatistic::load();
switch (auth()->user()->sport_id) {
case 1:
return [
Stat::make('1X2', '1X2')->view('filament.resources.events.widgets.alarm-widget',
['filter' => 'odds_3ways', 'title' => '1X2', 'red' => $res['odds_3ways'][3] ?? 0, 'yellow' => $res['odds_3ways'][2] ?? 0, 'green' => $res['odds_3ways'][1] ?? 0]),
Stat::make('1X2', '1X2')->view('filament.resources.events.widgets.alarm-widget',
['filter' => 'odds_3ways_ht', 'title' => '1X2 HT', 'red' => $res['odds_3ways_ht'][3] ?? 0, 'yellow' => $res['odds_3ways_ht'][2] ?? 0, 'green' => $res['odds_3ways_ht'][1] ?? 0]),
Stat::make('', '')->view('filament.resources.events.widgets.alarm-widget',
['filter' => 'odds_totals', 'title' => 'Totals', 'red' => $res['odds_totals'][3] ?? 0, 'yellow' => $res['odds_totals'][2] ?? 0, 'green' => $res['odds_totals'][1] ?? 0]),
Stat::make('', '')->view('filament.resources.events.widgets.alarm-widget',
['filter' => 'odds_totals_ht', 'title' => 'Totals HT', 'red' => $res['odds_totals_ht'][3] ?? 0, 'yellow' => $res['odds_totals_ht'][2] ?? 0, 'green' => $res['odds_totals_ht'][1] ?? 0]),
Stat::make('', '')->view('filament.resources.events.widgets.alarm-widget',
['filter' => 'odds_ggng', 'title' => 'GG NG', 'red' => $res['odds_ggng'][3] ?? 0, 'yellow' => $res['odds_ggng'][2] ?? 0, 'green' => $res['odds_ggng'][1] ?? 0]),
Stat::make('', '')->view('filament.resources.events.widgets.alarm-widget',
['filter' => 'odds_dnb', 'title' => 'DNB', 'red' => $res['odds_dnb'][3] ?? 0, 'yellow' => $res['odds_dnb'][2] ?? 0, 'green' => $res['odds_dnb'][1] ?? 0]),
Stat::make('', '')->view('filament.resources.events.widgets.alarm-widget',
['filter' => 'odds_dc', 'title' => 'DC', 'red' => $res['odds_dc'][3] ?? 0, 'yellow' => $res['odds_dc'][2] ?? 0, 'green' => $res['odds_dc'][1] ?? 0]),
Stat::make('', '')->view('filament.resources.events.widgets.alarm-widget',
['filter' => 'odds_tq', 'title' => 'TQ', 'red' => $res['odds_tq'][3] ?? 0, 'yellow' => $res['odds_tq'][2] ?? 0, 'green' => $res['odds_tq'][1] ?? 0]),
];
case 2:
return [
Stat::make('1X2', '1X2')->view('filament.resources.events.widgets.alarm-widget',
['filter' => 'odds_3ways', 'title' => '1X2', 'red' => $res['odds_3ways'][3] ?? 0, 'yellow' => $res['odds_3ways'][2] ?? 0, 'green' => $res['odds_3ways'][1] ?? 0]),
Stat::make('', '')->view('filament.resources.events.widgets.alarm-widget',
['filter' => 'odds_2ways', 'title' => 'ML', 'red' => $res['odds_2ways'][3] ?? 0, 'yellow' => $res['odds_2ways'][2] ?? 0, 'green' => $res['odds_2ways'][1] ?? 0]),
Stat::make('', '')->view('filament.resources.events.widgets.alarm-widget',
['filter' => 'odds_points', 'title' => 'PO', 'red' => $res['odds_points'][3] ?? 0, 'yellow' => $res['odds_points'][2] ?? 0, 'green' => $res['odds_points'][1] ?? 0]),
Stat::make('', '')->view('filament.resources.events.widgets.alarm-widget',
['filter' => 'odds_points_q1', 'title' => 'PO Q1', 'red' => $res['odds_points_q1'][3] ?? 0, 'yellow' => $res['odds_points_q1'][2] ?? 0, 'green' => $res['odds_points_q1'][1] ?? 0]),
Stat::make('', '')->view('filament.resources.events.widgets.alarm-widget',
['filter' => 'odds_totals', 'title' => 'Totals', 'red' => $res['odds_totals'][3] ?? 0, 'yellow' => $res['odds_totals'][2] ?? 0, 'green' => $res['odds_totals'][1] ?? 0]),
Stat::make('', '')->view('filament.resources.events.widgets.alarm-widget',
['filter' => 'odds_totals_q1', 'title' => 'Totals Q1', 'red' => $res['odds_totals_q1'][3] ?? 0, 'yellow' => $res['odds_totals_q1'][2] ?? 0, 'green' => $res['odds_totals_q1'][1] ?? 0]),
];
case 3:
return [
Stat::make('', '')->view('filament.resources.events.widgets.alarm-widget',
['filter' => 'odds_2ways', 'title' => 'ML', 'red' => $res['odds_2ways'][3] ?? 0, 'yellow' => $res['odds_2ways'][2] ?? 0, 'green' => $res['odds_2ways'][1] ?? 0]),
Stat::make('', '')->view('filament.resources.events.widgets.alarm-widget',
['filter' => 'odds_points', 'title' => 'PO', 'red' => $res['odds_points'][3] ?? 0, 'yellow' => $res['odds_points'][2] ?? 0, 'green' => $res['odds_points'][1] ?? 0]),
Stat::make('', '')->view('filament.resources.events.widgets.alarm-widget',
['filter' => 'odds_points_q1', 'title' => 'PO Q1', 'red' => $res['odds_points_q1'][3] ?? 0, 'yellow' => $res['odds_points_q1'][2] ?? 0, 'green' => $res['odds_points_q1'][1] ?? 0]),
Stat::make('', '')->view('filament.resources.events.widgets.alarm-widget',
['filter' => 'odds_points_ht', 'title' => 'PO HT', 'red' => $res['odds_points_ht'][3] ?? 0, 'yellow' => $res['odds_points_ht'][2] ?? 0, 'green' => $res['odds_points_ht'][1] ?? 0]),
Stat::make('', '')->view('filament.resources.events.widgets.alarm-widget',
['filter' => 'odds_totals', 'title' => 'Totals', 'red' => $res['odds_totals'][3] ?? 0, 'yellow' => $res['odds_totals'][2] ?? 0, 'green' => $res['odds_totals'][1] ?? 0]),
Stat::make('', '')->view('filament.resources.events.widgets.alarm-widget',
['filter' => 'odds_totals_q1', 'title' => 'Totals Q1', 'red' => $res['odds_totals_q1'][3] ?? 0, 'yellow' => $res['odds_totals_q1'][2] ?? 0, 'green' => $res['odds_totals_q1'][1] ?? 0]),
Stat::make('', '')->view('filament.resources.events.widgets.alarm-widget',
['filter' => 'odds_totals_ht', 'title' => 'Totals HT', 'red' => $res['odds_totals_ht'][3] ?? 0, 'yellow' => $res['odds_totals_ht'][2] ?? 0, 'green' => $res['odds_totals_ht'][1] ?? 0]),
];
case 5:
return [
Stat::make('', '')->view('filament.resources.events.widgets.alarm-widget',
['filter' => 'odds_2ways', 'title' => 'ML', 'red' => $res['odds_2ways'][3] ?? 0, 'yellow' => $res['odds_2ways'][2] ?? 0, 'green' => $res['odds_2ways'][1] ?? 0]),
Stat::make('', '')->view('filament.resources.events.widgets.alarm-widget',
['filter' => 'odds_2ways_s1', 'title' => 'MLS1', 'red' => $res['odds_2ways_s1'][3] ?? 0, 'yellow' => $res['odds_2ways_s1'][2] ?? 0, 'green' => $res['odds_2ways_s1'][1] ?? 0]),
Stat::make('', '')->view('filament.resources.events.widgets.alarm-widget',
['filter' => 'odds_points', 'title' => 'PO', 'red' => $res['odds_points'][3] ?? 0, 'yellow' => $res['odds_points'][2] ?? 0, 'green' => $res['odds_points'][1] ?? 0]),
Stat::make('', '')->view('filament.resources.events.widgets.alarm-widget',
['filter' => 'odds_totals', 'title' => 'Totals', 'red' => $res['odds_totals'][3] ?? 0, 'yellow' => $res['odds_totals'][2] ?? 0, 'green' => $res['odds_totals'][1] ?? 0]),
];
}
return [];
}
public function filterAlarm($table, $alarm)
{
switch ($alarm) {
case 1:
$this->dispatch('filterUpdateGreen', $table);
break;
case 2:
$this->dispatch('filterUpdateYellow', $table);
break;
case 3:
$this->dispatch('filterUpdateRed', $table);
break;
}
}
public function getColumns(): int|array
{
return [
'md' => 6,
'xl' => 8,
];
}
}