From 399b9d43a7925bdaba30594f24d968a334a17ad8 Mon Sep 17 00:00:00 2001 From: salam Date: Fri, 22 Aug 2025 06:23:28 +0200 Subject: [PATCH] wip --- .../Resources/Clients/ClientResource.php | 58 +++++++ .../Resources/Clients/Pages/CreateClient.php | 11 ++ .../Resources/Clients/Pages/EditClient.php | 19 +++ .../Resources/Clients/Pages/ListClients.php | 19 +++ .../Resources/Clients/Schemas/ClientForm.php | 25 +++ .../Resources/Clients/Tables/ClientsTable.php | 30 ++++ .../Resources/Users/Schemas/UserForm.php | 12 +- app/Filament/Resources/Users/UserResource.php | 2 + app/Models/Bookmaker.php | 10 ++ app/Models/Client.php | 24 +++ app/Models/ClientBookmaker.php | 24 +++ app/Policies/ClientPolicy.php | 108 +++++++++++++ app/Policies/UserPolicy.php | 144 ++++++++++++++++++ config/filament-shield.php | 2 +- ...4_11_08_053426_create_odds_3ways_table.php | 2 + ...4_11_08_053430_create_odds_2ways_table.php | 2 + ...2024_11_08_053430_create_odds_dc_table.php | 38 +++++ ...024_11_08_053430_create_odds_dnb_table.php | 2 + ...24_11_08_053430_create_odds_ggng_table.php | 37 +++++ ...11_08_053430_create_odds_qualify_table.php | 37 +++++ ..._08_053439_create_odds_handicaps_table.php | 2 + ..._11_08_053445_create_odds_totals_table.php | 4 +- ...2025_05_17_074607_create_clients_table.php | 1 + ...6_051927_create_event_bookmakers_table.php | 78 ---------- ...62942_add_custom_fields_to_users_table.php | 28 ---- ...4_062943_add_avatar_url_to_users_table.php | 28 ---- ...25_08_14_132404_create_customers_table.php | 27 ---- 27 files changed, 605 insertions(+), 169 deletions(-) create mode 100644 app/Filament/Resources/Clients/ClientResource.php create mode 100644 app/Filament/Resources/Clients/Pages/CreateClient.php create mode 100644 app/Filament/Resources/Clients/Pages/EditClient.php create mode 100644 app/Filament/Resources/Clients/Pages/ListClients.php create mode 100644 app/Filament/Resources/Clients/Schemas/ClientForm.php create mode 100644 app/Filament/Resources/Clients/Tables/ClientsTable.php create mode 100644 app/Models/Bookmaker.php create mode 100644 app/Models/Client.php create mode 100644 app/Models/ClientBookmaker.php create mode 100644 app/Policies/ClientPolicy.php create mode 100644 app/Policies/UserPolicy.php create mode 100644 database/migrations/2024_11_08_053430_create_odds_dc_table.php create mode 100644 database/migrations/2024_11_08_053430_create_odds_ggng_table.php create mode 100644 database/migrations/2024_11_08_053430_create_odds_qualify_table.php delete mode 100644 database/migrations/2025_05_26_051927_create_event_bookmakers_table.php delete mode 100644 database/migrations/2025_08_14_062942_add_custom_fields_to_users_table.php delete mode 100644 database/migrations/2025_08_14_062943_add_avatar_url_to_users_table.php delete mode 100644 database/migrations/2025_08_14_132404_create_customers_table.php diff --git a/app/Filament/Resources/Clients/ClientResource.php b/app/Filament/Resources/Clients/ClientResource.php new file mode 100644 index 00000000..f8b52fc3 --- /dev/null +++ b/app/Filament/Resources/Clients/ClientResource.php @@ -0,0 +1,58 @@ + ListClients::route('/'), + ]; + } + + public static function getNavigationBadge(): ?string + { + return parent::getEloquentQuery()->count(); + } +} diff --git a/app/Filament/Resources/Clients/Pages/CreateClient.php b/app/Filament/Resources/Clients/Pages/CreateClient.php new file mode 100644 index 00000000..9c57f131 --- /dev/null +++ b/app/Filament/Resources/Clients/Pages/CreateClient.php @@ -0,0 +1,11 @@ +components([ + TextInput::make('name') + ->required(), + TextInput::make('icon'), + Select::make('bookmaker') + ->relationship('bookmaker', 'name') + ->multiple() + ->preload() + ->searchable(), + ]); + } +} diff --git a/app/Filament/Resources/Clients/Tables/ClientsTable.php b/app/Filament/Resources/Clients/Tables/ClientsTable.php new file mode 100644 index 00000000..2086c439 --- /dev/null +++ b/app/Filament/Resources/Clients/Tables/ClientsTable.php @@ -0,0 +1,30 @@ +columns([ + // + ]) + ->filters([ + // + ]) + ->recordActions([ + EditAction::make(), + ]) + ->toolbarActions([ + BulkActionGroup::make([ + DeleteBulkAction::make(), + ]), + ]); + } +} diff --git a/app/Filament/Resources/Users/Schemas/UserForm.php b/app/Filament/Resources/Users/Schemas/UserForm.php index 2f678716..f6e5c425 100644 --- a/app/Filament/Resources/Users/Schemas/UserForm.php +++ b/app/Filament/Resources/Users/Schemas/UserForm.php @@ -3,7 +3,7 @@ namespace App\Filament\Resources\Users\Schemas; use Filament\Forms\Components\DateTimePicker; -use Filament\Forms\Components\Textarea; +use Filament\Forms\Components\Select; use Filament\Forms\Components\TextInput; use Filament\Schemas\Schema; @@ -23,11 +23,11 @@ class UserForm TextInput::make('password') ->password() ->required(), - Textarea::make('custom_fields') - ->default(null) - ->columnSpanFull(), - TextInput::make('avatar_url') - ->default(null), + Select::make('roles') + ->relationship('roles', 'name') + ->multiple() + ->preload() + ->searchable(), ]); } } diff --git a/app/Filament/Resources/Users/UserResource.php b/app/Filament/Resources/Users/UserResource.php index 959813e5..71206f6f 100644 --- a/app/Filament/Resources/Users/UserResource.php +++ b/app/Filament/Resources/Users/UserResource.php @@ -19,6 +19,8 @@ class UserResource extends Resource { protected static ?string $model = User::class; + protected static ?int $navigationSort = 31; + protected static string|BackedEnum|null $navigationIcon = 'lucide-user'; protected static ?string $cluster = MaintenanceCluster::class; diff --git a/app/Models/Bookmaker.php b/app/Models/Bookmaker.php new file mode 100644 index 00000000..7dc363d2 --- /dev/null +++ b/app/Models/Bookmaker.php @@ -0,0 +1,10 @@ +hasMany(ClientSports::class); + } + + public function client_bookmaker() + { + return $this->hasMany(ClientBookmaker::class); + } +} diff --git a/app/Models/ClientBookmaker.php b/app/Models/ClientBookmaker.php new file mode 100644 index 00000000..8ef356e5 --- /dev/null +++ b/app/Models/ClientBookmaker.php @@ -0,0 +1,24 @@ +belongsTo(Client::class); + } + + public function bookmaker() + { + return $this->belongsTo(Bookmaker::class); + } +} diff --git a/app/Policies/ClientPolicy.php b/app/Policies/ClientPolicy.php new file mode 100644 index 00000000..ab10f67f --- /dev/null +++ b/app/Policies/ClientPolicy.php @@ -0,0 +1,108 @@ +can('view_any_clients::client'); + } + + /** + * Determine whether the user can view the model. + */ + public function view(User $user, Client $client): bool + { + return $user->can('view_clients::client'); + } + + /** + * Determine whether the user can create models. + */ + public function create(User $user): bool + { + return $user->can('create_clients::client'); + } + + /** + * Determine whether the user can update the model. + */ + public function update(User $user, Client $client): bool + { + return $user->can('update_clients::client'); + } + + /** + * Determine whether the user can delete the model. + */ + public function delete(User $user, Client $client): bool + { + return $user->can('delete_clients::client'); + } + + /** + * Determine whether the user can bulk delete. + */ + public function deleteAny(User $user): bool + { + return $user->can('delete_any_clients::client'); + } + + /** + * Determine whether the user can permanently delete. + */ + public function forceDelete(User $user, Client $client): bool + { + return $user->can('force_delete_clients::client'); + } + + /** + * Determine whether the user can permanently bulk delete. + */ + public function forceDeleteAny(User $user): bool + { + return $user->can('force_delete_any_clients::client'); + } + + /** + * Determine whether the user can restore. + */ + public function restore(User $user, Client $client): bool + { + return $user->can('restore_clients::client'); + } + + /** + * Determine whether the user can bulk restore. + */ + public function restoreAny(User $user): bool + { + return $user->can('restore_any_clients::client'); + } + + /** + * Determine whether the user can replicate. + */ + public function replicate(User $user, Client $client): bool + { + return $user->can('replicate_clients::client'); + } + + /** + * Determine whether the user can reorder. + */ + public function reorder(User $user): bool + { + return $user->can('reorder_clients::client'); + } +} diff --git a/app/Policies/UserPolicy.php b/app/Policies/UserPolicy.php new file mode 100644 index 00000000..a64e9503 --- /dev/null +++ b/app/Policies/UserPolicy.php @@ -0,0 +1,144 @@ +can('view_any_users::user'); + } + + /** + * Determine whether the user can view the model. + * + * @param \App\Models\User $user + * @return bool + */ + public function view(User $user): bool + { + return $user->can('view_users::user'); + } + + /** + * Determine whether the user can create models. + * + * @param \App\Models\User $user + * @return bool + */ + public function create(User $user): bool + { + return $user->can('create_users::user'); + } + + /** + * Determine whether the user can update the model. + * + * @param \App\Models\User $user + * @return bool + */ + public function update(User $user): bool + { + return $user->can('update_users::user'); + } + + /** + * Determine whether the user can delete the model. + * + * @param \App\Models\User $user + * @return bool + */ + public function delete(User $user): bool + { + return $user->can('delete_users::user'); + } + + /** + * Determine whether the user can bulk delete. + * + * @param \App\Models\User $user + * @return bool + */ + public function deleteAny(User $user): bool + { + return $user->can('delete_any_users::user'); + } + + /** + * Determine whether the user can permanently delete. + * + * @param \App\Models\User $user + * @return bool + */ + public function forceDelete(User $user): bool + { + return $user->can('force_delete_users::user'); + } + + /** + * Determine whether the user can permanently bulk delete. + * + * @param \App\Models\User $user + * @return bool + */ + public function forceDeleteAny(User $user): bool + { + return $user->can('force_delete_any_users::user'); + } + + /** + * Determine whether the user can restore. + * + * @param \App\Models\User $user + * @return bool + */ + public function restore(User $user): bool + { + return $user->can('restore_users::user'); + } + + /** + * Determine whether the user can bulk restore. + * + * @param \App\Models\User $user + * @return bool + */ + public function restoreAny(User $user): bool + { + return $user->can('restore_any_users::user'); + } + + /** + * Determine whether the user can bulk restore. + * + * @param \App\Models\User $user + * @return bool + */ + public function replicate(User $user): bool + { + return $user->can('replicate_users::user'); + } + + /** + * Determine whether the user can reorder. + * + * @param \App\Models\User $user + * @return bool + */ + public function reorder(User $user): bool + { + return $user->can('reorder_users::user'); + } +} diff --git a/config/filament-shield.php b/config/filament-shield.php index f9d859d2..9cb3a2e5 100644 --- a/config/filament-shield.php +++ b/config/filament-shield.php @@ -4,7 +4,7 @@ return [ 'shield_resource' => [ 'should_register_navigation' => true, 'slug' => 'shield/roles', - 'navigation_sort' => -1, + 'navigation_sort' => 32, 'navigation_badge' => true, 'navigation_group' => true, 'sub_navigation_position' => null, diff --git a/database/migrations/2024_11_08_053426_create_odds_3ways_table.php b/database/migrations/2024_11_08_053426_create_odds_3ways_table.php index b1083a61..20880202 100644 --- a/database/migrations/2024_11_08_053426_create_odds_3ways_table.php +++ b/database/migrations/2024_11_08_053426_create_odds_3ways_table.php @@ -21,6 +21,8 @@ return new class extends Migration $table->decimal('draw', 7, 3)->default(0); $table->decimal('away', 7, 3)->default(0); $table->decimal('margin', 7, 3)->default(0); + $table->boolean('flag')->default(0); + $table->boolean('check')->default(0); $table->integer('add_time')->default(0); $table->timestamps(); diff --git a/database/migrations/2024_11_08_053430_create_odds_2ways_table.php b/database/migrations/2024_11_08_053430_create_odds_2ways_table.php index e52eda1d..3fb8df13 100644 --- a/database/migrations/2024_11_08_053430_create_odds_2ways_table.php +++ b/database/migrations/2024_11_08_053430_create_odds_2ways_table.php @@ -20,6 +20,8 @@ return new class extends Migration $table->decimal('home', 7, 3)->default(0); $table->decimal('away', 7, 3)->default(0); $table->decimal('margin', 7, 3)->default(0); + $table->boolean('flag')->default(0); + $table->boolean('check')->default(0); $table->integer('add_time')->default(0); $table->timestamps(); }); diff --git a/database/migrations/2024_11_08_053430_create_odds_dc_table.php b/database/migrations/2024_11_08_053430_create_odds_dc_table.php new file mode 100644 index 00000000..2c8c94e8 --- /dev/null +++ b/database/migrations/2024_11_08_053430_create_odds_dc_table.php @@ -0,0 +1,38 @@ +id(); + $table->foreignId('event_id')->constrained()->cascadeOnDelete(); + $table->integer('sport_id')->default(0); + $table->integer('matchpart_id')->default(0); + $table->integer('bookmaker_id')->default(0); + $table->decimal('dc1x', 7, 3)->default(0); + $table->decimal('dc12', 7, 3)->default(0); + $table->decimal('dc2x', 7, 3)->default(0); + $table->decimal('margin', 7, 3)->default(0); + $table->boolean('flag')->default(0); + $table->boolean('check')->default(0); + $table->integer('add_time')->default(0); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('odds_dc'); + } +}; diff --git a/database/migrations/2024_11_08_053430_create_odds_dnb_table.php b/database/migrations/2024_11_08_053430_create_odds_dnb_table.php index 8b32e7d1..2f240c43 100644 --- a/database/migrations/2024_11_08_053430_create_odds_dnb_table.php +++ b/database/migrations/2024_11_08_053430_create_odds_dnb_table.php @@ -20,6 +20,8 @@ return new class extends Migration $table->decimal('dnb1', 7, 3)->default(0); $table->decimal('dnb2', 7, 3)->default(0); $table->decimal('margin', 7, 3)->default(0); + $table->boolean('flag')->default(0); + $table->boolean('check')->default(0); $table->integer('add_time')->default(0); $table->timestamps(); }); diff --git a/database/migrations/2024_11_08_053430_create_odds_ggng_table.php b/database/migrations/2024_11_08_053430_create_odds_ggng_table.php new file mode 100644 index 00000000..929a7f02 --- /dev/null +++ b/database/migrations/2024_11_08_053430_create_odds_ggng_table.php @@ -0,0 +1,37 @@ +id(); + $table->foreignId('event_id')->constrained()->cascadeOnDelete(); + $table->integer('sport_id')->default(0); + $table->integer('matchpart_id')->default(0); + $table->integer('bookmaker_id')->default(0); + $table->decimal('gg', 7, 3)->default(0); + $table->decimal('ng', 7, 3)->default(0); + $table->decimal('margin', 7, 3)->default(0); + $table->boolean('flag')->default(0); + $table->boolean('check')->default(0); + $table->integer('add_time')->default(0); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('odds_ggng'); + } +}; diff --git a/database/migrations/2024_11_08_053430_create_odds_qualify_table.php b/database/migrations/2024_11_08_053430_create_odds_qualify_table.php new file mode 100644 index 00000000..51e23562 --- /dev/null +++ b/database/migrations/2024_11_08_053430_create_odds_qualify_table.php @@ -0,0 +1,37 @@ +id(); + $table->foreignId('event_id')->constrained()->cascadeOnDelete(); + $table->integer('sport_id')->default(0); + $table->integer('matchpart_id')->default(0); + $table->integer('bookmaker_id')->default(0); + $table->decimal('htq', 7, 3)->default(0); + $table->decimal('atq', 7, 3)->default(0); + $table->decimal('margin', 7, 3)->default(0); + $table->boolean('flag')->default(0); + $table->boolean('check')->default(0); + $table->integer('add_time')->default(0); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('odds_qualify'); + } +}; diff --git a/database/migrations/2024_11_08_053439_create_odds_handicaps_table.php b/database/migrations/2024_11_08_053439_create_odds_handicaps_table.php index 99279493..f6fbb5ca 100644 --- a/database/migrations/2024_11_08_053439_create_odds_handicaps_table.php +++ b/database/migrations/2024_11_08_053439_create_odds_handicaps_table.php @@ -21,6 +21,8 @@ return new class extends Migration $table->decimal('away', 7, 3)->default(0); $table->decimal('handicap', 7, 3)->default(0); $table->decimal('margin', 7, 3)->default(0); + $table->boolean('flag')->default(0); + $table->boolean('check')->default(0); $table->integer('add_time')->default(0); $table->timestamps(); }); diff --git a/database/migrations/2024_11_08_053445_create_odds_totals_table.php b/database/migrations/2024_11_08_053445_create_odds_totals_table.php index 86443133..dce45c1b 100644 --- a/database/migrations/2024_11_08_053445_create_odds_totals_table.php +++ b/database/migrations/2024_11_08_053445_create_odds_totals_table.php @@ -19,8 +19,10 @@ return new class extends Migration $table->integer('bookmaker_id')->default(0); $table->decimal('over', 7, 3)->default(0); $table->decimal('under', 7, 3)->default(0); - $table->decimal('spread', 7, 3)->default(0); + $table->decimal('total', 7, 3)->default(0); $table->decimal('margin', 7, 3)->default(0); + $table->boolean('flag')->default(0); + $table->boolean('check')->default(0); $table->integer('add_time')->default(0); $table->timestamps(); diff --git a/database/migrations/2025_05_17_074607_create_clients_table.php b/database/migrations/2025_05_17_074607_create_clients_table.php index f78dcc3b..549e9057 100644 --- a/database/migrations/2025_05_17_074607_create_clients_table.php +++ b/database/migrations/2025_05_17_074607_create_clients_table.php @@ -15,6 +15,7 @@ return new class extends Migration $table->id(); $table->string('name'); $table->string('icon')->nullable(); + $table->string('homepage')->nullable(); $table->timestamps(); }); } diff --git a/database/migrations/2025_05_26_051927_create_event_bookmakers_table.php b/database/migrations/2025_05_26_051927_create_event_bookmakers_table.php deleted file mode 100644 index 52c457fd..00000000 --- a/database/migrations/2025_05_26_051927_create_event_bookmakers_table.php +++ /dev/null @@ -1,78 +0,0 @@ -id(); - $table->foreignId('event_id')->constrained()->cascadeOnDelete(); - $table->timestamp('time')->nullable(); - $table->integer('bkid')->default(0); - $table->string('boid')->nullable(); - - // flag status - $table->integer('flag')->default(0); - // swop (inverted odds) - $table->integer('swop')->default(0); - - // 1x2 - $table->decimal('h3w', 7, 3)->default(0); - $table->decimal('d3w', 7, 3)->default(0); - $table->decimal('a3w', 7, 3)->default(0); - $table->decimal('m3w', 7, 3)->default(0); - $table->integer('f3w')->default(0); - // bookmaker offer id - - // Total - $table->decimal('ov', 7, 3)->default(0); - $table->decimal('un', 7, 3)->default(0); - $table->decimal('hc', 7, 3)->default(0); - $table->decimal('mto', 7, 3)->default(0); - $table->integer('fto')->default(0); - - // ML - $table->decimal('h2w', 7, 3)->default(0); - $table->decimal('a2w', 7, 3)->default(0); - $table->decimal('m2w', 7, 3)->default(0); - $table->integer('f2w')->default(0); - - // DC - $table->decimal('dc1x', 7, 3)->default(0); - $table->decimal('dc12', 7, 3)->default(0); - $table->decimal('dc2x', 7, 3)->default(0); - $table->decimal('mdc', 7, 3)->default(0); - $table->integer('fdc')->default(0); - - // GG NG - $table->decimal('gg', 7, 3)->default(0); - $table->decimal('ng', 7, 3)->default(0); - $table->decimal('mgg', 7, 3)->default(0); - $table->integer('fgg')->default(0); - - // TO QUALIFY - $table->decimal('htq', 7, 3)->default(0); - $table->decimal('atq', 7, 3)->default(0); - $table->decimal('mtq', 7, 3)->default(0); - $table->integer('ftq')->default(0); - - $table->timestamps(); - $table->index(['event_id', 'boid', 'bkid', 'flag']); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('event_bookmakers'); - } -}; diff --git a/database/migrations/2025_08_14_062942_add_custom_fields_to_users_table.php b/database/migrations/2025_08_14_062942_add_custom_fields_to_users_table.php deleted file mode 100644 index eb4f9902..00000000 --- a/database/migrations/2025_08_14_062942_add_custom_fields_to_users_table.php +++ /dev/null @@ -1,28 +0,0 @@ -json('custom_fields')->nullable(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::table('users', function (Blueprint $table) { - $table->dropColumn('custom_fields'); - }); - } -}; diff --git a/database/migrations/2025_08_14_062943_add_avatar_url_to_users_table.php b/database/migrations/2025_08_14_062943_add_avatar_url_to_users_table.php deleted file mode 100644 index 5627ef35..00000000 --- a/database/migrations/2025_08_14_062943_add_avatar_url_to_users_table.php +++ /dev/null @@ -1,28 +0,0 @@ -string(config('filament-edit-profile.avatar_column', 'avatar_url'))->nullable(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::table('users', function (Blueprint $table) { - $table->dropColumn(config('filament-edit-profile.avatar_column', 'avatar_url')); - }); - } -}; diff --git a/database/migrations/2025_08_14_132404_create_customers_table.php b/database/migrations/2025_08_14_132404_create_customers_table.php deleted file mode 100644 index 5e1f0d5d..00000000 --- a/database/migrations/2025_08_14_132404_create_customers_table.php +++ /dev/null @@ -1,27 +0,0 @@ -id(); - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('customers'); - } -};