toggle difference s book and partner; remove sport froma larm filter
This commit is contained in:
1 parent
7c0fd2b7a0
commit
4e64f2f318
12 files changed
+84
-90
No files matched your search
@@ -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]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -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'];
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -1,42 +1,25 @@
|
||||
<div class="flex flex-row gap-2">
|
||||
|
||||
<x-filament::dropdown>
|
||||
<x-slot name="trigger">
|
||||
<x-filament::button size="xs" color="gray" wire:poll.20s="setDifferences">
|
||||
Missing
|
||||
@if ($this->bookmakerPartnerDiffrences == 0)
|
||||
<x-filament::badge size="xs" color="gray">
|
||||
0
|
||||
</x-filament::badge>
|
||||
@else
|
||||
<x-filament::badge size="xs" color="danger">
|
||||
{{ $this->bookmakerPartnerDiffrences }}
|
||||
</x-filament::badge>
|
||||
@endif
|
||||
</x-filament::button>
|
||||
</x-slot>
|
||||
|
||||
<x-filament::dropdown.list>
|
||||
<x-filament::dropdown.list.item>
|
||||
{{ auth()->user()->bookmaker->name }}
|
||||
|
||||
<x-filament::badge size="xs" wire:poll.20s="countBookmaker">
|
||||
{{ $this->bookmakerCount }}
|
||||
|
||||
</x-filament::badge>
|
||||
</x-filament::dropdown.list.item>
|
||||
|
||||
<x-filament::dropdown.list.item>
|
||||
{{ auth()->user()->partnerbookmaker->name }}
|
||||
|
||||
<x-filament::badge size="xs" wire:click.20s="countPartner">
|
||||
{{ $this->partnerCount }}
|
||||
</x-filament::badge>
|
||||
</x-filament::dropdown.list.item>
|
||||
|
||||
</x-filament::dropdown.list>
|
||||
</x-filament::dropdown>
|
||||
|
||||
<x-filament::button size="xs" wire:poll.20s="setDifferences" :color="auth()->user()->bookmaker_partner_differences ? 'home' : 'gray'"
|
||||
wire:click="toggleBookmakerPartnerDiffrences"
|
||||
tooltip="{{ auth()->user()->bookmaker->name .
|
||||
' ' .
|
||||
$this->bookmakerCount .
|
||||
' - ' .
|
||||
auth()->user()->partnerbookmaker->name .
|
||||
' ' .
|
||||
$this->partnerCount }}">
|
||||
Missing
|
||||
@if ($this->bookmakerPartnerDiffrences == 0)
|
||||
<x-filament::badge size="xs" color="gray">
|
||||
0
|
||||
</x-filament::badge>
|
||||
@else
|
||||
<x-filament::badge size="xs" color="danger">
|
||||
{{ $this->bookmakerPartnerDiffrences }}
|
||||
</x-filament::badge>
|
||||
@endif
|
||||
</x-filament::button>
|
||||
|
||||
<div></div>
|
||||
<div></div>
|
||||
@@ -59,7 +42,7 @@
|
||||
</x-filament::button>
|
||||
|
||||
<x-filament::button disabled="true" size="xs" wire:click="toggleComparePartner"
|
||||
tooltip="Differences {{ auth()->user()->bookmaker->name }} vs {{ auth()->user()->partnerbookmaker->name }}"
|
||||
tooltip="Highlight different odds {{ auth()->user()->bookmaker->name }} vs {{ auth()->user()->partnerbookmaker->name }}"
|
||||
:disabled="auth()->user()->partner_show ? false : true" :color="auth()->user()->partner_compare ? 'info' : 'gray'" icon="phosphor-exclude-square-duotone">
|
||||
</x-filament::button>
|
||||
|
||||
|
||||
Reference in new issue
Block a user