notification & notes wip

This commit is contained in:
salam committed 2026-02-01 16:36:27 +01:00
1 parent 94a3c6c472
commit 155177045b
30 files changed
+426 -320

No files matched your search

@@ -14,6 +14,8 @@ use App\Models\CompetitionGroup;
use App\Models\Country;
use App\Models\Event;
use App\Models\EventBookmaker;
use App\Models\EventUserNote;
use App\Models\EventUserNotification;
use App\Models\EventUserStar;
use App\Models\Group;
use App\Models\OddsTable;
@@ -23,14 +25,15 @@ use Filament\Actions\ActionGroup;
use Filament\Actions\BulkActionGroup;
use Filament\Actions\DeleteAction;
use Filament\Actions\DeleteBulkAction;
use Filament\Actions\EditAction;
use Filament\Actions\ViewAction;
use Filament\Forms\Components\Hidden;
use Filament\Forms\Components\Radio;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Toggle;
use Filament\Schemas\Components\Utilities\Get;
use Filament\Support\Enums\FontWeight;
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;
@@ -61,9 +64,9 @@ class EventsTable
return $table
->striped()
->poll('5s')
->poll('10s')
->deferLoading()
->defaultPaginationPageOption(50)
->defaultPaginationPageOption(5)
->paginated([5, 10, 15])
->columns([
IconColumn::make('sport.icon')
@@ -168,7 +171,8 @@ class EventsTable
->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'])
])
->searchable(['id', 'home.name', 'away.name', 'betsapi_id', 'betradar_id', 'bet365_id', 'bwin_id', 'event_bookmaker.event_id'])
->defaultSort('starttime', 'ASC')
->extremePaginationLinks()
->filters([
@@ -479,9 +483,9 @@ class EventsTable
}
}
if ($data['stars_status'] ?? null) {
$indicators[] = Indicator::make('Favorits')->removeField('stars_status')->color('info');
}
// if ($data['stars_filter'] ?? null) {
// $indicators[] = Indicator::make('Favorits')->removeField('stars_filter')->color('info');
// }
if ($data['filter_compare_differences'] ?? null) {
$opt = explode('-', $data['filter_compare_differences']);
@@ -539,8 +543,126 @@ class EventsTable
EventUserStar::insert(['event_id' => $record->id, 'user_id' => auth()->user()->id]);
}
}),
EditAction::make()->iconButton()->color(fn ($record) => $record->user_notes->isEmpty() ? 'gray' : 'info')->icon('phosphor-note-pencil'),
ViewAction::make()->iconButton()->color('gray')->icon('phosphor-note-pencil'),
Action::make('event_note')
->modalIcon('phosphor-note')
->modalWidth(Width::Large)
->modalSubmitActionLabel('Save')
->extraModalFooterActions(fn (Action $action): array => [
$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'),
TextInput::make('message')->prefixIcon('phosphor-note-pencil')->hiddenLabel()->live()
->extraInputAttributes(['onClick' => 'this.select()']),
])
->icon('phosphor-note-pencil')
->iconButton()
->tooltip(fn ($record) => view('filament.resources.events.tooltip.event-user-note-tooltip', ['notes' => $record->event_user_note]))
->action(function ($record, array $data) {
if ($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'),
Action::make('event_notification')
->modalWidth(Width::Large)
->modalSubmitActionLabel('Save')
->extraModalFooterActions(fn (Action $action): array => [
$action->makeModalSubmitAction('Delete', arguments: ['delete' => true])->color('danger'),
])
->modalIcon('phosphor-bell')
->fillForm(data: function ($record) {
foreach ($record->event_user_notification as $value) {
if ($value->user_id == auth()->user()->id && $value->bookmaker_id == auth()->user()->bookmaker_id) {
return [
'event_user_notification_id' => $value->id,
'odds_table_id' => $value->odds_table_id,
'alarm_level_id' => $value->alarm_level_id,
'is_notified' => $value->is_notified,
'notify_by_email' => $value->notify_by_email,
];
}
}
return ['event_user_notification_id' => ''];
})
->schema([
Hidden::make('event_user_notification_id'),
Toggle::make('is_notified')->label('Monitoring')
->aboveContent('If a notification has been send "Monitoring" will be off')
->onColor('gray')
->offColor('info'),
Select::make('odds_table_id')
->label('Monitor Bettype Favorit')
->belowContent('Favorit is compared with bookmaker favorit filtert by method')
->required()
->prefixIcon('phosphor-dots-three-outline-vertical')
->native(false)
->options(fn ($record) => OddsTable::options_sport()),
Radio::make('alarm_level_id')
->label('Alarm level')
->required()
->inline()
->belowContent('If favorit enters alarm level a notification will be send.')
->options([
'1' => 'Level 1',
'2' => 'Level 2',
'3' => 'Level 3',
]),
Toggle::make('notify_by_email')->label('E-Mail')
->belowContent('Notify me also by e-mail')
->onColor('info')
->offColor('gray'),
])
->icon('phosphor-bell')
->iconButton()
->action(function ($record, array $data) {
if ($data['event_user_notification_id']) {
EventUserNotification::where('id', $data['event_user_notification_id'])->update([
'odds_table_id' => $data['odds_table_id'],
'alarm_level_id' => $data['alarm_level_id'],
'notify_by_email' => $data['notify_by_email'],
'is_notified' => $data['is_notified'],
]);
} else {
EventUserNotification::updateOrCreate([
'event_id' => $record->id,
'bookmaker_id' => auth()->user()->bookmaker_id,
'user_id' => auth()->user()->id,
], [
'odds_table_id' => $data['odds_table_id'],
'alarm_level_id' => $data['alarm_level_id'],
'notify_by_email' => $data['notify_by_email'],
'is_notified' => $data['is_notified'],
]);
}
})
->color(fn ($record) => $record->event_user_notification->isEmpty() ? 'gray' : 'info'),
ActionGroup::make([
DeleteAction::make()->visible(fn () => auth()->user()->hasRole('super_admin')),
Action::make('txodds_odds')