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();
|
$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(
|
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]
|
['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();
|
$users = User::with('client')->get();
|
||||||
foreach ($users as $user) {
|
foreach ($users as $user) {
|
||||||
if (in_array($user->id, [1, 2])) {
|
foreach ($alarm_levels as $alarm_level) {
|
||||||
$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) {
|
|
||||||
|
|
||||||
|
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(
|
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]
|
['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\EventsTable;
|
||||||
use App\Filament\Resources\Events\Tables\Tools\LoadPartnerDifferences;
|
use App\Filament\Resources\Events\Tables\Tools\LoadPartnerDifferences;
|
||||||
use App\Models\Event;
|
use App\Models\Event;
|
||||||
|
use App\Models\EventBookmaker;
|
||||||
use Filament\Resources\Resource;
|
use Filament\Resources\Resource;
|
||||||
use Filament\Schemas\Schema;
|
use Filament\Schemas\Schema;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
@@ -80,6 +81,17 @@ class EventResource extends Resource
|
|||||||
$query->whereIn('id', $event_ids);
|
$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 (isset((EventsTable::$bettype_settings))) {
|
||||||
if (in_array('odds_2ways', EventsTable::$bettype_settings)) {
|
if (in_array('odds_2ways', EventsTable::$bettype_settings)) {
|
||||||
$query->with('odds_2ways.bookmaker');
|
$query->with('odds_2ways.bookmaker');
|
||||||
|
|||||||
@@ -41,6 +41,11 @@ class ListEvents extends ListRecords
|
|||||||
// $this->dispatch('refreshMapperRight');
|
// $this->dispatch('refreshMapperRight');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function updateCompareDifferences(): void
|
||||||
|
{
|
||||||
|
$this->tableFilters['events']['bookmaker_partner_differences'] = ! $this->tableFilters['events']['bookmaker_partner_differences'];
|
||||||
|
}
|
||||||
|
|
||||||
public function updateStar(): void
|
public function updateStar(): void
|
||||||
{
|
{
|
||||||
$this->tableFilters['events']['filter_stars'] = ! $this->tableFilters['events']['filter_stars'];
|
$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);
|
$indicators[] = Indicator::make('With '.auth()->user()->partnerbookmaker->name)->color('info')->removable(false);
|
||||||
}
|
}
|
||||||
if (auth()->user()->partner_compare == 1) {
|
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) {
|
if ($data['filter_notes'] ?? null) {
|
||||||
|
|||||||
@@ -28,7 +28,9 @@ class BettypeToggle extends Component
|
|||||||
$this->bettype_toggles = [];
|
$this->bettype_toggles = [];
|
||||||
|
|
||||||
$this->countBookmaker();
|
$this->countBookmaker();
|
||||||
|
|
||||||
$this->countPartner();
|
$this->countPartner();
|
||||||
|
|
||||||
$this->setDifferences();
|
$this->setDifferences();
|
||||||
|
|
||||||
$res = BettypeUser::with('multiline_setting')
|
$res = BettypeUser::with('multiline_setting')
|
||||||
@@ -62,6 +64,7 @@ class BettypeToggle extends Component
|
|||||||
public function toggleBettype($multiline_setting_id)
|
public function toggleBettype($multiline_setting_id)
|
||||||
{
|
{
|
||||||
BettypeUser::where('multiline_setting_id', $multiline_setting_id)->update(['is_active' => DB::raw('!is_active')]);
|
BettypeUser::where('multiline_setting_id', $multiline_setting_id)->update(['is_active' => DB::raw('!is_active')]);
|
||||||
|
|
||||||
$this->dispatch('refreshBettypeMenu');
|
$this->dispatch('refreshBettypeMenu');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,8 +139,7 @@ class BettypeToggle extends Component
|
|||||||
|
|
||||||
public function setAllOnlyNone($value)
|
public function setAllOnlyNone($value)
|
||||||
{
|
{
|
||||||
|
User::where('id', auth()->user()->id)->update(['all_only_none' => $value]);
|
||||||
$user = User::where('id', auth()->user()->id)->update(['all_only_none' => $value]);
|
|
||||||
|
|
||||||
$this->dispatch('refreshBettypeMenu');
|
$this->dispatch('refreshBettypeMenu');
|
||||||
}
|
}
|
||||||
@@ -156,8 +158,26 @@ class BettypeToggle extends Component
|
|||||||
->count();
|
->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()
|
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\Filament\Tables\Columns\BookmakerIcon;
|
||||||
use App\Models\Bookmaker;
|
use App\Models\Bookmaker;
|
||||||
use App\Models\PersonalNotification;
|
use App\Models\PersonalNotification;
|
||||||
use App\Models\Sport;
|
|
||||||
use Filament\Actions\Action;
|
use Filament\Actions\Action;
|
||||||
use Filament\Actions\Concerns\InteractsWithActions;
|
use Filament\Actions\Concerns\InteractsWithActions;
|
||||||
use Filament\Actions\Contracts\HasActions;
|
use Filament\Actions\Contracts\HasActions;
|
||||||
use Filament\Schemas\Concerns\InteractsWithSchemas;
|
use Filament\Schemas\Concerns\InteractsWithSchemas;
|
||||||
use Filament\Schemas\Contracts\HasSchemas;
|
use Filament\Schemas\Contracts\HasSchemas;
|
||||||
use Filament\Support\Enums\FontWeight;
|
use Filament\Support\Enums\FontWeight;
|
||||||
use Filament\Support\Enums\IconSize;
|
|
||||||
use Filament\Tables\Columns\IconColumn;
|
|
||||||
use Filament\Tables\Columns\TextColumn;
|
use Filament\Tables\Columns\TextColumn;
|
||||||
use Filament\Tables\Concerns\InteractsWithTable;
|
use Filament\Tables\Concerns\InteractsWithTable;
|
||||||
use Filament\Tables\Contracts\HasTable;
|
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.')
|
->description('Send a notification when favorit enters an alarm level.')
|
||||||
->striped()
|
->striped()
|
||||||
->columns([
|
->columns([
|
||||||
// TextColumn::make('sport.name'),
|
|
||||||
BookmakerIcon::make('bookmaker.icon')
|
BookmakerIcon::make('bookmaker.icon')
|
||||||
->label('Bookmaker')->size('lg'),
|
->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')
|
TextColumn::make('alarm_level.name')
|
||||||
->color(fn ($record) => $record->alarm_level->color)
|
->color(fn ($record) => $record->alarm_level->color)
|
||||||
->weight(FontWeight::Black)
|
->weight(FontWeight::Black)
|
||||||
@@ -60,12 +51,6 @@ class PersonalNotificationTable extends Component implements HasActions, HasSche
|
|||||||
->selectablePlaceholder(false)
|
->selectablePlaceholder(false)
|
||||||
->options(Bookmaker::options([auth()->user()->partner_bookmaker_id, auth()->user()->bookmaker_id]))
|
->options(Bookmaker::options([auth()->user()->partner_bookmaker_id, auth()->user()->bookmaker_id]))
|
||||||
->preload(),
|
->preload(),
|
||||||
SelectFilter::make('sport_id')
|
|
||||||
->label('Sport')
|
|
||||||
->default(1)
|
|
||||||
->selectablePlaceholder(false)
|
|
||||||
->options(Sport::getSportForClient(auth()->user()->client_id))
|
|
||||||
->preload(),
|
|
||||||
], FiltersLayout::AboveContent)
|
], FiltersLayout::AboveContent)
|
||||||
->filtersFormColumns(3)
|
->filtersFormColumns(3)
|
||||||
->hiddenFilterIndicators()
|
->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]);
|
PersonalNotification::where('id', $record->id)->update(['notify_by_email' => ! $record->notify_by_email]);
|
||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function render(): View
|
public function render(): View
|
||||||
|
|||||||
@@ -8,18 +8,12 @@ class PersonalNotification extends Model
|
|||||||
{
|
{
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'user_id',
|
'user_id',
|
||||||
'sport_id',
|
|
||||||
'bookmaker_id',
|
'bookmaker_id',
|
||||||
'alarm_level_id',
|
'alarm_level_id',
|
||||||
'notify_by_system',
|
'notify_by_system',
|
||||||
'notify_by_email',
|
'notify_by_email',
|
||||||
];
|
];
|
||||||
|
|
||||||
public function sport()
|
|
||||||
{
|
|
||||||
return $this->belongsTo(Sport::class);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function bookmaker()
|
public function bookmaker()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Bookmaker::class);
|
return $this->belongsTo(Bookmaker::class);
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ class User extends Authenticatable implements FilamentUser, HasAppAuthentication
|
|||||||
'all_only_none',
|
'all_only_none',
|
||||||
'partner_show',
|
'partner_show',
|
||||||
'partner_compare',
|
'partner_compare',
|
||||||
|
'bookmaker_partner_differences',
|
||||||
'bookmaker_id',
|
'bookmaker_id',
|
||||||
'partner_bookmaker_id',
|
'partner_bookmaker_id',
|
||||||
'provider_id',
|
'provider_id',
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ return new class extends Migration
|
|||||||
$table->boolean('all_only_none')->default(false);
|
$table->boolean('all_only_none')->default(false);
|
||||||
$table->boolean('partner_show')->default(false);
|
$table->boolean('partner_show')->default(false);
|
||||||
$table->boolean('partner_compare')->default(false);
|
$table->boolean('partner_compare')->default(false);
|
||||||
|
$table->boolean('bookmaker_partner_differences')->default(false);
|
||||||
$table->timestamp('app_verified_at')->nullable();
|
$table->timestamp('app_verified_at')->nullable();
|
||||||
|
|
||||||
$table->rememberToken();
|
$table->rememberToken();
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ return new class extends Migration
|
|||||||
Schema::create('personal_notifications', function (Blueprint $table) {
|
Schema::create('personal_notifications', function (Blueprint $table) {
|
||||||
$table->id();
|
$table->id();
|
||||||
$table->integer('user_id')->index()->references('id')->on('users');
|
$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('bookmaker_id')->index()->references('id')->on('bookmakers');
|
||||||
$table->integer('alarm_level_id')->default(0);
|
$table->integer('alarm_level_id')->default(0);
|
||||||
$table->boolean('notify_by_system')->default(false);
|
$table->boolean('notify_by_system')->default(false);
|
||||||
|
|||||||
@@ -1,42 +1,25 @@
|
|||||||
<div class="flex flex-row gap-2">
|
<div class="flex flex-row gap-2">
|
||||||
|
|
||||||
<x-filament::dropdown>
|
<x-filament::button size="xs" wire:poll.20s="setDifferences" :color="auth()->user()->bookmaker_partner_differences ? 'home' : 'gray'"
|
||||||
<x-slot name="trigger">
|
wire:click="toggleBookmakerPartnerDiffrences"
|
||||||
<x-filament::button size="xs" color="gray" wire:poll.20s="setDifferences">
|
tooltip="{{ auth()->user()->bookmaker->name .
|
||||||
Missing
|
' ' .
|
||||||
@if ($this->bookmakerPartnerDiffrences == 0)
|
$this->bookmakerCount .
|
||||||
<x-filament::badge size="xs" color="gray">
|
' - ' .
|
||||||
0
|
auth()->user()->partnerbookmaker->name .
|
||||||
</x-filament::badge>
|
' ' .
|
||||||
@else
|
$this->partnerCount }}">
|
||||||
<x-filament::badge size="xs" color="danger">
|
Missing
|
||||||
{{ $this->bookmakerPartnerDiffrences }}
|
@if ($this->bookmakerPartnerDiffrences == 0)
|
||||||
</x-filament::badge>
|
<x-filament::badge size="xs" color="gray">
|
||||||
@endif
|
0
|
||||||
</x-filament::button>
|
</x-filament::badge>
|
||||||
</x-slot>
|
@else
|
||||||
|
<x-filament::badge size="xs" color="danger">
|
||||||
<x-filament::dropdown.list>
|
{{ $this->bookmakerPartnerDiffrences }}
|
||||||
<x-filament::dropdown.list.item>
|
</x-filament::badge>
|
||||||
{{ auth()->user()->bookmaker->name }}
|
@endif
|
||||||
|
</x-filament::button>
|
||||||
<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>
|
|
||||||
|
|
||||||
|
|
||||||
<div></div>
|
<div></div>
|
||||||
<div></div>
|
<div></div>
|
||||||
@@ -59,7 +42,7 @@
|
|||||||
</x-filament::button>
|
</x-filament::button>
|
||||||
|
|
||||||
<x-filament::button disabled="true" size="xs" wire:click="toggleComparePartner"
|
<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">
|
:disabled="auth()->user()->partner_show ? false : true" :color="auth()->user()->partner_compare ? 'info' : 'gray'" icon="phosphor-exclude-square-duotone">
|
||||||
</x-filament::button>
|
</x-filament::button>
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user