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

+55 -56
View File
@@ -3,9 +3,6 @@
namespace App\Filament\Resources\Events;
use App\Filament\Resources\Events\Pages\ListEvents;
use App\Filament\Resources\Events\RelationManagers\BettypesRelationManager;
use App\Filament\Resources\Events\RelationManagers\CountriesRelationManager;
use App\Filament\Resources\Events\RelationManagers\UserNoteRelationManager;
use App\Filament\Resources\Events\Schemas\EventForm;
use App\Filament\Resources\Events\Tables\EventsTable;
use App\Filament\Resources\Events\Tables\Tools\LoadPartnerDifferences;
@@ -46,15 +43,6 @@ class EventResource extends Resource
];
}
public static function getRelations(): array
{
return [
UserNoteRelationManager::class,
CountriesRelationManager::class,
BettypesRelationManager::class,
];
}
public static function getNavigationBadge(): ?string
{
return parent::getEloquentQuery()
@@ -70,16 +58,25 @@ class EventResource extends Resource
->with('country')
->with('home')
->with('away')
->with('event_user_star')
->with('event_bookmaker')
->with('user_notes')
->with('event_user_star')
->with('event_user_note')
->with('event_user_notification')
->where('sport_id', auth()->user()->sport_id)
->where('starttime', '>=', now());
if (auth()->user()->stars) {
if (auth()->user()->filter_stars) {
$query->whereHas('event_user_star');
}
if (auth()->user()->filter_notes) {
$query->whereHas('event_user_note');
}
if (auth()->user()->filter_notification) {
$query->whereHas('event_user_notification');
}
if (auth()->user()->all_only_none > 0) {
switch (auth()->user()->all_only_none) {
case 1:
@@ -96,47 +93,49 @@ class EventResource extends Resource
$query->whereIn('id', $event_ids);
}
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');
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;
@@ -1,60 +0,0 @@
<?php
namespace App\Filament\Resources\Events\RelationManagers;
use Filament\Actions\AssociateAction;
use Filament\Actions\BulkActionGroup;
use Filament\Actions\CreateAction;
use Filament\Actions\DeleteAction;
use Filament\Actions\DeleteBulkAction;
use Filament\Actions\DissociateAction;
use Filament\Actions\DissociateBulkAction;
use Filament\Actions\EditAction;
use Filament\Forms\Components\TextInput;
use Filament\Resources\RelationManagers\RelationManager;
use Filament\Schemas\Schema;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
class BettypesRelationManager extends RelationManager
{
protected static string $relationship = 'bettypes';
public function form(Schema $schema): Schema
{
return $schema
->components([
TextInput::make('name')
->required()
->maxLength(255),
]);
}
public function table(Table $table): Table
{
return $table
->recordTitleAttribute('name')
->columns([
TextColumn::make('name')
->searchable(),
])
->filters([
//
])
->headerActions([
CreateAction::make(),
AssociateAction::make(),
])
->recordActions([
EditAction::make(),
DissociateAction::make(),
DeleteAction::make(),
])
->toolbarActions([
BulkActionGroup::make([
DissociateBulkAction::make(),
DeleteBulkAction::make(),
]),
]);
}
}
@@ -1,60 +0,0 @@
<?php
namespace App\Filament\Resources\Events\RelationManagers;
use Filament\Actions\AssociateAction;
use Filament\Actions\BulkActionGroup;
use Filament\Actions\CreateAction;
use Filament\Actions\DeleteAction;
use Filament\Actions\DeleteBulkAction;
use Filament\Actions\DissociateAction;
use Filament\Actions\DissociateBulkAction;
use Filament\Actions\EditAction;
use Filament\Forms\Components\TextInput;
use Filament\Resources\RelationManagers\RelationManager;
use Filament\Schemas\Schema;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
class CountriesRelationManager extends RelationManager
{
protected static string $relationship = 'countries';
public function form(Schema $schema): Schema
{
return $schema
->components([
TextInput::make('name')
->required()
->maxLength(255),
]);
}
public function table(Table $table): Table
{
return $table
->recordTitleAttribute('name')
->columns([
TextColumn::make('name')
->searchable(),
])
->filters([
//
])
->headerActions([
CreateAction::make(),
AssociateAction::make(),
])
->recordActions([
EditAction::make(),
DissociateAction::make(),
DeleteAction::make(),
])
->toolbarActions([
BulkActionGroup::make([
DissociateBulkAction::make(),
DeleteBulkAction::make(),
]),
]);
}
}
@@ -1,55 +0,0 @@
<?php
namespace App\Filament\Resources\Events\RelationManagers;
use Filament\Actions\CreateAction;
use Filament\Actions\DeleteAction;
use Filament\Actions\EditAction;
use Filament\Forms\Components\TextInput;
use Filament\Resources\RelationManagers\RelationManager;
use Filament\Schemas\Schema;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
class UserNoteRelationManager extends RelationManager
{
protected static string $relationship = 'user_notes';
protected static ?string $title = 'Allgemeinflächen';
protected static ?string $navigationLabel = 'Allgemeinflächen';
protected static ?string $modelLabel = 'Allgemeinflächen';
protected static ?string $pluralModelLabel = 'Allgemeinflächen';
public function form(Schema $schema): Schema
{
return $schema
->components([
TextInput::make('event_id')
->required()
->maxLength(255),
]);
}
public function table(Table $table): Table
{
return $table
->recordTitleAttribute('event_id')
->columns([
TextColumn::make('event_id')
->searchable(),
])
->filters([
//
])
->headerActions([
CreateAction::make(),
])
->recordActions([
EditAction::make(),
DeleteAction::make(),
]);
}
}
@@ -12,9 +12,9 @@ class EventForm
return $schema
->components([
TextInput::make('provider_id')
->numeric()
->default(0),
// TextInput::make('provider_id')
// ->numeric()
// ->default(0),
]);
}
}
@@ -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')
@@ -15,7 +15,7 @@ class AlarmWidget extends StatsOverviewWidget
'refreshAlarmWidget' => '$refresh',
];
protected ?string $pollingInterval = '10s';
protected ?string $pollingInterval = '15s';
public array $filters = [];