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

+11 -11
View File
@@ -3,7 +3,6 @@
namespace App\Actions;
use App\Models\Event;
use App\Models\EventBookmaker;
use App\Models\OddsTable;
class AlarmStatistic
@@ -16,19 +15,21 @@ class AlarmStatistic
$fields[$value->name] = explode(',', $value->fieldnames);
}
$event_ids = Event::where('sport_id', auth()->user()->sport_id)->where('starttime', '>=', now())->pluck('id')->toArray();
$res = EventBookmaker::select('alarm_2w_h2w', 'alarm_2w_a2w', 'alarm_2ws1_h2w', 'alarm_2ws1_a2w', 'alarm_3w_h3w', 'alarm_3w_d3w', 'alarm_3w_a3w', 'alarm_3wht_h3w', 'alarm_3wht_d3w', 'alarm_3wht_a3w', 'alarm_dc_dc1x', 'alarm_dc_dc12', 'alarm_dc_dcx2', 'alarm_dbn_dnb1', 'alarm_dbn_dnb2', 'alarm_ggng_gg', 'alarm_ggng_ng', 'alarm_po_home', 'alarm_po_away', 'alarm_poht_home', 'alarm_poht_away', 'alarm_poq1_home', 'alarm_poq1_away', 'alarm_to_over', 'alarm_to_under', 'alarm_toht_over', 'alarm_toht_under', 'alarm_toq1_over', 'alarm_toq1_under', 'alarm_tq_htq', 'alarm_tq_atq')
->whereIn('event_id', $event_ids)
->where('bookmaker_id', auth()->user()->bookmaker_id)
->get()
->toArray();
$events = Event::with('event_bookmaker')
->where('sport_id', auth()->user()->sport_id)
->where('starttime', '>=', now())
->whereHas('event_bookmaker', function ($query) {
$query->where('bookmaker_id', auth()->user()->bookmaker_id);
})
->get();
$arr = [];
foreach ($res as $value) {
foreach ($events as $event) {
$row = $event->event_bookmaker;
// $row = get_object_vars($event->toArray());
foreach ($fields as $table => $names) {
foreach ($names as $name) {
$val = (int) $value[$name];
$val = (int) $row[$name];
if ($val) {
if (isset($arr[$table][$val])) {
$arr[$table][$val]++;
@@ -37,7 +38,6 @@ class AlarmStatistic
}
}
}
}
}
+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 = [];
+17 -1
View File
@@ -49,7 +49,23 @@ class BettypeToggle extends Component
public function toggleStar()
{
User::where('id', auth()->user()->id)->update(['stars' => DB::raw('!stars')]);
User::where('id', auth()->user()->id)->update(['filter_stars' => DB::raw('!filter_stars')]);
$this->dispatch('filterClearFilter');
$this->dispatch('refreshBettypeMenu');
}
public function toggleNote()
{
User::where('id', auth()->user()->id)->update(['filter_notes' => DB::raw('!filter_notes')]);
$this->dispatch('filterClearFilter');
$this->dispatch('refreshBettypeMenu');
}
public function toggleNotification()
{
User::where('id', auth()->user()->id)->update(['filter_notification' => DB::raw('!filter_notification')]);
$this->dispatch('filterClearFilter');
$this->dispatch('refreshBettypeMenu');
+10 -5
View File
@@ -53,11 +53,6 @@ class Event extends Model
return $this->belongsTo(Group::class);
}
public function user_notes()
{
return $this->hasMany(UserNote::class, 'event_id', 'id');
}
public function competition_group()
{
return $this->belongsTo(CompetitionGroup::class);
@@ -148,6 +143,16 @@ class Event extends Model
return $this->hasOne(EventUserStar::class, 'event_id', 'id');
}
public function event_user_note()
{
return $this->hasMany(EventUserNote::class, 'event_id', 'id');
}
public function event_user_notification()
{
return $this->hasMany(EventUserNotification::class, 'event_id', 'id');
}
public function event_bookmaker()
{
return $this->hasOne(EventBookmaker::class, 'event_id', 'id')->where('bookmaker_id', auth()->user()->bookmaker_id);
@@ -5,10 +5,9 @@ namespace App\Models;
use App\Models\Scopes\ClientScope;
use Illuminate\Database\Eloquent\Model;
class UserNote extends Model
class EventUserNote extends Model
{
protected $fillable = [
'user_messageid',
'event_id',
'bookmaker_id',
'user_id',
@@ -4,13 +4,16 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class UserNotification extends Model
class EventUserNotification extends Model
{
protected $fillable = [
'event_id',
'bookmaker_id',
'user_id',
'message',
'odds_table_id',
'alarm_level_id',
'notify_by_email',
'is_notified',
'deleted',
];
+17
View File
@@ -30,4 +30,21 @@ class OddsTable extends Model
return $arr;
}
public static function options_sport()
{
switch (auth()->user()->sport_id) {
case 1:
return OddsTable::where('soccer', 1)->pluck('fulltitle', 'id');
case 2:
return OddsTable::where('icehockey', 1)->pluck('fulltitle', 'id');
case 3:
return OddsTable::where('basketball', 1)->pluck('fulltitle', 'id');
case 5:
return OddsTable::where('tennis', 1)->pluck('fulltitle', 'id');
}
return [];
}
}
+3 -1
View File
@@ -34,7 +34,9 @@ class User extends Authenticatable implements FilamentUser, HasAppAuthentication
'app_verified_at',
'client_id',
'sport_id',
'star',
'filter_stars',
'filter_notes',
'filter_notification',
'is_multiline_direct',
'all_only_none',
'partner_show',