diff --git a/app/Actions/SettingGeneratorUser.php b/app/Actions/SettingGeneratorUser.php index ebfb8dca..af3f6385 100644 --- a/app/Actions/SettingGeneratorUser.php +++ b/app/Actions/SettingGeneratorUser.php @@ -42,20 +42,18 @@ class SettingGeneratorUser } $alarm_levels = AlarmLevel::get(); - foreach ($sports as $sport_id) { - foreach ($alarm_levels as $alarm_level) { + foreach ($alarm_levels as $alarm_level) { + PersonalNotification::firstOrCreate( + ['user_id' => $record->id, 'bookmaker_id' => $record->bookmaker_id, 'alarm_level_id' => $alarm_level->id], + ['notify_by_system' => 0, 'notify_by_email' => 0] + ); + + if ($record->partner_bookmaker_id) { PersonalNotification::firstOrCreate( - ['sport_id' => $sport_id, 'user_id' => $record->id, 'bookmaker_id' => $record->bookmaker_id, 'alarm_level_id' => $alarm_level->id], + ['user_id' => $record->id, 'bookmaker_id' => $record->partner_bookmaker_id, 'alarm_level_id' => $alarm_level->id], ['notify_by_system' => 0, 'notify_by_email' => 0] ); - - if ($record->partner_bookmaker_id) { - PersonalNotification::firstOrCreate( - ['sport_id' => $sport_id, 'user_id' => $record->id, 'bookmaker_id' => $record->partner_bookmaker_id, 'alarm_level_id' => $alarm_level->id], - ['notify_by_system' => 0, 'notify_by_email' => 0] - ); - } } } diff --git a/app/Console/Commands/Services/Tasks/GenerateSetting.php b/app/Console/Commands/Services/Tasks/GenerateSetting.php index 7a446d7d..8310b562 100644 --- a/app/Console/Commands/Services/Tasks/GenerateSetting.php +++ b/app/Console/Commands/Services/Tasks/GenerateSetting.php @@ -185,25 +185,18 @@ class GenerateSetting $users = User::with('client')->get(); foreach ($users as $user) { - if (in_array($user->id, [1, 2])) { - $sports = Sport::where('is_active', 1)->pluck('id')->toArray(); - } else { - $sports = Client::find($user->client_id)->value('sport'); - } - foreach ($sports as $sport_id) { - foreach ($alarm_levels as $alarm_level) { + foreach ($alarm_levels as $alarm_level) { + PersonalNotification::firstOrCreate( + ['user_id' => $user->id, 'bookmaker_id' => $user->bookmaker_id, 'alarm_level_id' => $alarm_level->id], + ['notify_by_system' => 0, 'notify_by_email' => 0] + ); + + if ($user->partner_bookmaker_id) { PersonalNotification::firstOrCreate( - ['sport_id' => $sport_id, 'user_id' => $user->id, 'bookmaker_id' => $user->bookmaker_id, 'alarm_level_id' => $alarm_level->id], + ['user_id' => $user->id, 'bookmaker_id' => $user->partner_bookmaker_id, 'alarm_level_id' => $alarm_level->id], ['notify_by_system' => 0, 'notify_by_email' => 0] ); - - if ($user->partner_bookmaker_id) { - PersonalNotification::firstOrCreate( - ['sport_id' => $sport_id, 'user_id' => $user->id, 'bookmaker_id' => $user->partner_bookmaker_id, 'alarm_level_id' => $alarm_level->id], - ['notify_by_system' => 0, 'notify_by_email' => 0] - ); - } } } } diff --git a/app/Filament/Resources/Events/EventResource.php b/app/Filament/Resources/Events/EventResource.php index 65500bf9..1bf2803a 100644 --- a/app/Filament/Resources/Events/EventResource.php +++ b/app/Filament/Resources/Events/EventResource.php @@ -7,6 +7,7 @@ use App\Filament\Resources\Events\Schemas\EventForm; use App\Filament\Resources\Events\Tables\EventsTable; use App\Filament\Resources\Events\Tables\Tools\LoadPartnerDifferences; use App\Models\Event; +use App\Models\EventBookmaker; use Filament\Resources\Resource; use Filament\Schemas\Schema; use Filament\Tables\Table; @@ -80,6 +81,17 @@ class EventResource extends Resource $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); + } + if (isset((EventsTable::$bettype_settings))) { if (in_array('odds_2ways', EventsTable::$bettype_settings)) { $query->with('odds_2ways.bookmaker'); diff --git a/app/Filament/Resources/Events/Pages/ListEvents.php b/app/Filament/Resources/Events/Pages/ListEvents.php index 15c7f384..77aeb6c9 100644 --- a/app/Filament/Resources/Events/Pages/ListEvents.php +++ b/app/Filament/Resources/Events/Pages/ListEvents.php @@ -41,6 +41,11 @@ class ListEvents extends ListRecords // $this->dispatch('refreshMapperRight'); } + 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']; diff --git a/app/Filament/Resources/Events/Tables/EventsTable.php b/app/Filament/Resources/Events/Tables/EventsTable.php index a553cbe8..4cb28324 100644 --- a/app/Filament/Resources/Events/Tables/EventsTable.php +++ b/app/Filament/Resources/Events/Tables/EventsTable.php @@ -486,7 +486,11 @@ class EventsTable $indicators[] = Indicator::make('With '.auth()->user()->partnerbookmaker->name)->color('info')->removable(false); } if (auth()->user()->partner_compare == 1) { - $indicators[] = Indicator::make('Difference '.auth()->user()->bookmaker->name.' vs '.auth()->user()->partnerbookmaker->name)->color('info')->removable(false); + $indicators[] = Indicator::make('Difference odds '.auth()->user()->bookmaker->name.' vs '.auth()->user()->partnerbookmaker->name)->color('info')->removable(false); + } + + if (auth()->user()->bookmaker_partner_differences == 1) { + $indicators[] = Indicator::make('Different events '.auth()->user()->bookmaker->name.' vs '.auth()->user()->partnerbookmaker->name)->color('home'); } if ($data['filter_notes'] ?? null) { diff --git a/app/Livewire/BettypeToggle.php b/app/Livewire/BettypeToggle.php index cb1bccab..8750abdb 100644 --- a/app/Livewire/BettypeToggle.php +++ b/app/Livewire/BettypeToggle.php @@ -28,7 +28,9 @@ class BettypeToggle extends Component $this->bettype_toggles = []; $this->countBookmaker(); + $this->countPartner(); + $this->setDifferences(); $res = BettypeUser::with('multiline_setting') @@ -62,6 +64,7 @@ class BettypeToggle extends Component public function toggleBettype($multiline_setting_id) { BettypeUser::where('multiline_setting_id', $multiline_setting_id)->update(['is_active' => DB::raw('!is_active')]); + $this->dispatch('refreshBettypeMenu'); } @@ -136,8 +139,7 @@ class BettypeToggle extends Component public function setAllOnlyNone($value) { - - $user = User::where('id', auth()->user()->id)->update(['all_only_none' => $value]); + User::where('id', auth()->user()->id)->update(['all_only_none' => $value]); $this->dispatch('refreshBettypeMenu'); } @@ -156,8 +158,26 @@ class BettypeToggle extends Component ->count(); } + public function toggleBookmakerPartnerDiffrences() + { + User::where('id', auth()->user()->id)->update(['bookmaker_partner_differences' => DB::raw('!bookmaker_partner_differences')]); + + $this->dispatch('updateCompareDifferences'); + + $this->dispatch('refreshBettypeMenu'); + + } + public function setDifferences() { - $this->bookmakerPartnerDiffrences = abs($this->bookmakerCount - $this->partnerCount); + $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); + + $this->bookmakerPartnerDiffrences = \count($result); } } diff --git a/app/Livewire/PersonalNotificationTable.php b/app/Livewire/PersonalNotificationTable.php index 8d9cf384..a8f66646 100644 --- a/app/Livewire/PersonalNotificationTable.php +++ b/app/Livewire/PersonalNotificationTable.php @@ -5,15 +5,12 @@ namespace App\Livewire; use App\Filament\Tables\Columns\BookmakerIcon; use App\Models\Bookmaker; use App\Models\PersonalNotification; -use App\Models\Sport; use Filament\Actions\Action; use Filament\Actions\Concerns\InteractsWithActions; use Filament\Actions\Contracts\HasActions; use Filament\Schemas\Concerns\InteractsWithSchemas; use Filament\Schemas\Contracts\HasSchemas; use Filament\Support\Enums\FontWeight; -use Filament\Support\Enums\IconSize; -use Filament\Tables\Columns\IconColumn; use Filament\Tables\Columns\TextColumn; use Filament\Tables\Concerns\InteractsWithTable; use Filament\Tables\Contracts\HasTable; @@ -36,14 +33,8 @@ class PersonalNotificationTable extends Component implements HasActions, HasSche ->description('Send a notification when favorit enters an alarm level.') ->striped() ->columns([ - // TextColumn::make('sport.name'), BookmakerIcon::make('bookmaker.icon') ->label('Bookmaker')->size('lg'), - // IconColumn::make('sport.icon') - // ->label('') - // ->color(fn ($record) => $record->sport->color) - // ->icon(fn ($record) => $record->sport->icon) - // ->size(IconSize::ExtraLarge), TextColumn::make('alarm_level.name') ->color(fn ($record) => $record->alarm_level->color) ->weight(FontWeight::Black) @@ -60,12 +51,6 @@ class PersonalNotificationTable extends Component implements HasActions, HasSche ->selectablePlaceholder(false) ->options(Bookmaker::options([auth()->user()->partner_bookmaker_id, auth()->user()->bookmaker_id])) ->preload(), - SelectFilter::make('sport_id') - ->label('Sport') - ->default(1) - ->selectablePlaceholder(false) - ->options(Sport::getSportForClient(auth()->user()->client_id)) - ->preload(), ], FiltersLayout::AboveContent) ->filtersFormColumns(3) ->hiddenFilterIndicators() @@ -87,7 +72,6 @@ class PersonalNotificationTable extends Component implements HasActions, HasSche PersonalNotification::where('id', $record->id)->update(['notify_by_email' => ! $record->notify_by_email]); }), ]); - } public function render(): View diff --git a/app/Models/PersonalNotification.php b/app/Models/PersonalNotification.php index 190a2283..d9709916 100644 --- a/app/Models/PersonalNotification.php +++ b/app/Models/PersonalNotification.php @@ -8,18 +8,12 @@ class PersonalNotification extends Model { protected $fillable = [ 'user_id', - 'sport_id', 'bookmaker_id', 'alarm_level_id', 'notify_by_system', 'notify_by_email', ]; - public function sport() - { - return $this->belongsTo(Sport::class); - } - public function bookmaker() { return $this->belongsTo(Bookmaker::class); diff --git a/app/Models/User.php b/app/Models/User.php index 486016db..8d875023 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -38,6 +38,7 @@ class User extends Authenticatable implements FilamentUser, HasAppAuthentication 'all_only_none', 'partner_show', 'partner_compare', + 'bookmaker_partner_differences', 'bookmaker_id', 'partner_bookmaker_id', 'provider_id', diff --git a/database/migrations/0001_01_01_000000_create_users_table.php b/database/migrations/0001_01_01_000000_create_users_table.php index 72d41d04..150d7a41 100644 --- a/database/migrations/0001_01_01_000000_create_users_table.php +++ b/database/migrations/0001_01_01_000000_create_users_table.php @@ -30,6 +30,7 @@ return new class extends Migration $table->boolean('all_only_none')->default(false); $table->boolean('partner_show')->default(false); $table->boolean('partner_compare')->default(false); + $table->boolean('bookmaker_partner_differences')->default(false); $table->timestamp('app_verified_at')->nullable(); $table->rememberToken(); diff --git a/database/migrations/2026_02_05_170620_create_personal_notifications_table.php b/database/migrations/2026_02_05_170620_create_personal_notifications_table.php index 81372e62..a026462e 100644 --- a/database/migrations/2026_02_05_170620_create_personal_notifications_table.php +++ b/database/migrations/2026_02_05_170620_create_personal_notifications_table.php @@ -14,7 +14,6 @@ return new class extends Migration Schema::create('personal_notifications', function (Blueprint $table) { $table->id(); $table->integer('user_id')->index()->references('id')->on('users'); - $table->integer('sport_id')->index()->references('id')->on('sports'); $table->integer('bookmaker_id')->index()->references('id')->on('bookmakers'); $table->integer('alarm_level_id')->default(0); $table->boolean('notify_by_system')->default(false); diff --git a/resources/views/livewire/bettype-toggle.blade.php b/resources/views/livewire/bettype-toggle.blade.php index ee487896..ee868036 100644 --- a/resources/views/livewire/bettype-toggle.blade.php +++ b/resources/views/livewire/bettype-toggle.blade.php @@ -1,42 +1,25 @@