diff --git a/app/Actions/AlarmStatistic.php b/app/Actions/AlarmStatistic.php index b4bc87e0..5791e360 100644 --- a/app/Actions/AlarmStatistic.php +++ b/app/Actions/AlarmStatistic.php @@ -2,6 +2,7 @@ namespace App\Actions; +use App\Models\Event; use App\Models\EventBookmaker; use App\Models\OddsTable; @@ -15,10 +16,11 @@ 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') - ->where('starttime', '>=', now()) + ->whereIn('event_id', $event_ids) ->where('bookmaker_id', auth()->user()->bookmaker_id) - ->where('sport_id', auth()->user()->sport_id) ->get() ->toArray(); diff --git a/app/Filament/Resources/Events/Tables/EventsTable.php b/app/Filament/Resources/Events/Tables/EventsTable.php index 5fa99570..dcbd9264 100644 --- a/app/Filament/Resources/Events/Tables/EventsTable.php +++ b/app/Filament/Resources/Events/Tables/EventsTable.php @@ -87,10 +87,6 @@ class EventsTable EventColumn::make('event'), - IconColumn::make('alarm')->icon('phosphor-sirene'), - - IconColumn::make('note')->icon('phosphor-note'), - TooltipOdds::make('ml')->bettype('odds_2ways')->label('')->visible(fn () => in_array('odds_2ways', self::$bettype_settings)), ColumnOdds::make('odds_2ways')->bettype('odds_2ways') ->visible(fn () => in_array('odds_2ways', self::$bettype_settings)) @@ -513,6 +509,8 @@ class EventsTable ->emptyStateHeading('No events') ->emptyStateDescription('Modify the filter') ->recordActions([ + Action::make('note')->iconButton()->icon('phosphor-note')->color('gray')->tooltip('Add a message'), + Action::make('notify')->iconButton()->icon('phosphor-bell')->color('gray')->tooltip('Add a notifications'), Action::make('star') ->iconButton() ->color(function ($record) { diff --git a/app/Models/Message.php b/app/Models/Message.php new file mode 100644 index 00000000..9c844496 --- /dev/null +++ b/app/Models/Message.php @@ -0,0 +1,26 @@ +belongsTo(User::class); + } + + public function bookmaker() + { + return $this->belongsTo(Bookmaker::class); + } +} diff --git a/app/Models/UserNotification.php b/app/Models/UserNotification.php new file mode 100644 index 00000000..dbf743b2 --- /dev/null +++ b/app/Models/UserNotification.php @@ -0,0 +1,31 @@ +belongsTo(User::class); + } + + public function bookmaker() + { + return $this->belongsTo(Bookmaker::class); + } + + public function odds_table() + { + return $this->belongsTo(OddsTable::class); + } +} diff --git a/database/migrations/2026_01_27_132542_create_odds_tables_table.php b/database/migrations/2026_01_27_132542_create_odds_tables_table.php index d5280a4b..0278e632 100644 --- a/database/migrations/2026_01_27_132542_create_odds_tables_table.php +++ b/database/migrations/2026_01_27_132542_create_odds_tables_table.php @@ -18,6 +18,10 @@ return new class extends Migration $table->boolean(column: 'has_active_spread')->default(0); $table->string('oddnames'); $table->string('fieldnames'); + $table->boolean('soccer')->default(false); + $table->boolean('icehockey')->default(false); + $table->boolean('basketball')->default(false); + $table->boolean('tennis')->default(false); $table->timestamps(); }); } diff --git a/database/migrations/2026_01_30_101858_create_messages_table.php b/database/migrations/2026_01_30_101858_create_messages_table.php new file mode 100644 index 00000000..394e6c34 --- /dev/null +++ b/database/migrations/2026_01_30_101858_create_messages_table.php @@ -0,0 +1,32 @@ +id(); + $table->foreignId('event_id')->index()->constrained()->cascadeOnDelete()->references('id')->on('events'); + $table->integer('bookmaker_id')->default(0); + $table->integer('user_id')->index()->references('id')->on('users'); + $table->string('message'); + $table->integer('deleted')->default(0); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('messages'); + } +}; diff --git a/database/migrations/2026_01_30_102545_create_user_notifications_table.php b/database/migrations/2026_01_30_102545_create_user_notifications_table.php new file mode 100644 index 00000000..d9aced95 --- /dev/null +++ b/database/migrations/2026_01_30_102545_create_user_notifications_table.php @@ -0,0 +1,34 @@ +id(); + $table->foreignId('event_id')->index()->constrained()->cascadeOnDelete()->references('id')->on('events'); + $table->integer('bookmaker_id')->default(0); + $table->integer('user_id')->index()->references('id')->on('users'); + $table->integer('odds_table_id')->index()->references('id')->on('odds_tables'); + $table->integer('alarm_level_id')->default(0); + $table->string('message'); + $table->integer('deleted')->default(0); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('user_notifications'); + } +}; diff --git a/database/seeders/OddsTableSeeder.php b/database/seeders/OddsTableSeeder.php index 0b58446a..96e1ca8d 100644 --- a/database/seeders/OddsTableSeeder.php +++ b/database/seeders/OddsTableSeeder.php @@ -12,22 +12,22 @@ class OddsTableSeeder extends Seeder /** * Provoider */ - $sql = "INSERT INTO `odds_tables` (`id`, `name`, `title`, `oddnames`, `fieldnames`, `has_active_spread`, `created_at`, `updated_at`) + $sql = "INSERT INTO `odds_tables` (`id`, `name`, `title`, `oddnames`, `fieldnames`, `has_active_spread`, `soccer`, `icehockey`, `basketball`, `tennis`, `created_at`, `updated_at`) VALUES - (1, 'odds_2ways', 'ML', 'h2w,a2w', 'alarm_2w_h2w,alarm_2w_a2w', 0, NULL, NULL), - (2, 'odds_2ways_s1', 'ML S1', 'h2w,a2w', 'alarm_2ws1_h2w,alarm_2ws1_a2w', 0, NULL, NULL), - (3, 'odds_3ways', '1X2', 'h3w,d3w,a3w', 'alarm_3w_h3w,alarm_3w_d3w,alarm_3w_a3w', 0, NULL, NULL), - (4, 'odds_3ways_ht', '1X2 HT', 'h3w,d3w,a3w', 'alarm_3wht_h3w,alarm_3wht_d3w,alarm_3wht_a3w', 0, NULL, NULL), - (5, 'odds_dc', 'DC', 'dc1x,dc12,dcx2', 'alarm_dc_dc1x,alarm_dc_dc12,alarm_dc_dcx2', 0, NULL, NULL), - (6, 'odds_dnb', 'DNB', 'dnb1,dnb2', 'alarm_dbn_dnb1,alarm_dbn_dnb2', 0, NULL, NULL), - (7, 'odds_ggng', 'GGNG', 'gg,ng', 'alarm_ggng_gg,alarm_ggng_ng', 0, NULL, NULL), - (8, 'odds_points', 'PO', 'home,away', 'alarm_po_home,alarm_po_away', 1, NULL, NULL), - (9, 'odds_points_ht', 'PO HT', 'home,away', 'alarm_poht_home,alarm_poht_away', 1, NULL, NULL), - (10, 'odds_points_q1', 'PO Q1', 'home,away', 'alarm_poq1_home,alarm_poq1_away', 1, NULL, NULL), - (11, 'odds_totals', 'TO', 'over,under', 'alarm_to_over,alarm_to_under', 1, NULL, NULL), - (12, 'odds_totals_ht', 'TO HT', 'over,under', 'alarm_toht_over,alarm_toht_under', 1, NULL, NULL), - (13, 'odds_totals_q1', 'TO Q1', 'over,under', 'alarm_toq1_over,alarm_toq1_under', 1, NULL, NULL), - (14, 'odds_tq', 'TQ', 'htq,atq', 'alarm_tq_htq,alarm_tq_atq', 1, NULL, NULL); + (1, 'odds_2ways', 'ML', 'h2w,a2w', 'alarm_2w_h2w,alarm_2w_a2w', 0, 0, 1, 1, 1, NULL, NULL), + (2, 'odds_2ways_s1', 'ML S1', 'h2w,a2w', 'alarm_2ws1_h2w,alarm_2ws1_a2w', 0, 0, 0, 0, 1, NULL, NULL), + (3, 'odds_3ways', '1X2', 'h3w,d3w,a3w', 'alarm_3w_h3w,alarm_3w_d3w,alarm_3w_a3w', 0, 1, 1, 0, 0, NULL, NULL), + (4, 'odds_3ways_ht', '1X2 HT', 'h3w,d3w,a3w', 'alarm_3wht_h3w,alarm_3wht_d3w,alarm_3wht_a3w', 0, 1, 0, 0, 0, NULL, NULL), + (5, 'odds_dc', 'DC', 'dc1x,dc12,dcx2', 'alarm_dc_dc1x,alarm_dc_dc12,alarm_dc_dcx2', 0, 1, 0, 0, 0, NULL, NULL), + (6, 'odds_dnb', 'DNB', 'dnb1,dnb2', 'alarm_dbn_dnb1,alarm_dbn_dnb2', 0, 1, 0, 0, 0, NULL, NULL), + (7, 'odds_ggng', 'GGNG', 'gg,ng', 'alarm_ggng_gg,alarm_ggng_ng', 0, 1, 0, 0, 0, NULL, NULL), + (8, 'odds_points', 'PO', 'home,away', 'alarm_po_home,alarm_po_away', 1, 0, 1, 1, 1, NULL, NULL), + (9, 'odds_points_ht', 'PO HT', 'home,away', 'alarm_poht_home,alarm_poht_away', 1, 0, 0, 1, 0, NULL, NULL), + (10, 'odds_points_q1', 'PO Q1', 'home,away', 'alarm_poq1_home,alarm_poq1_away', 1, 0, 1, 1, 0, NULL, NULL), + (11, 'odds_totals', 'TO', 'over,under', 'alarm_to_over,alarm_to_under', 1, 1, 1, 1, 1, NULL, NULL), + (12, 'odds_totals_ht', 'TO HT', 'over,under', 'alarm_toht_over,alarm_toht_under', 1, 1, 0, 1, 0, NULL, NULL), + (13, 'odds_totals_q1', 'TO Q1', 'over,under', 'alarm_toq1_over,alarm_toq1_under', 1, 0, 1, 1, 0, NULL, NULL), + (14, 'odds_tq', 'TQ', 'htq,atq', 'alarm_tq_htq,alarm_tq_atq', 1, 1, 0, 0, 0, NULL, NULL); "; DB::unprepared($sql); diff --git a/resources/views/filament/tables/columns/tooltip-odds.blade.php b/resources/views/filament/tables/columns/tooltip-odds.blade.php index c22460e4..03262841 100644 --- a/resources/views/filament/tables/columns/tooltip-odds.blade.php +++ b/resources/views/filament/tables/columns/tooltip-odds.blade.php @@ -3,13 +3,13 @@ $str = $getPop(); @endphp @if ($getSize()) -
+
-