diff --git a/app/Console/Commands/Grapper/TxOdds/Odds.php b/app/Console/Commands/Grapper/TxOdds/Odds.php index 1bb19b52..92731c17 100644 --- a/app/Console/Commands/Grapper/TxOdds/Odds.php +++ b/app/Console/Commands/Grapper/TxOdds/Odds.php @@ -129,6 +129,7 @@ class Odds /************************************************* * CALL *************************************************/ + $counter = 0; foreach ($_calls as $url) { $data = Xml::load($url); @@ -184,6 +185,8 @@ class Odds Nuh::$_event = Event::firstOrCreate($event, ['starttime' => $event['starttime']]); + $counter++; + foreach ($row->bookmaker as $book) { Nuh::$bookmaker_id = (int) $book['bid']; @@ -257,10 +260,10 @@ class Odds } } } + } - if ($debug) { - Notice::note('END '.Nuh::$_event->id, 'g'); - } + if ($debug) { + Notice::note('DONE - EVENTS: '.$counter, 'g'); } } } diff --git a/app/Filament/Resources/Countries/CountryResource.php b/app/Filament/Resources/Countries/CountryResource.php index b830179e..da040a4a 100644 --- a/app/Filament/Resources/Countries/CountryResource.php +++ b/app/Filament/Resources/Countries/CountryResource.php @@ -26,8 +26,6 @@ class CountryResource extends Resource protected static string|\BackedEnum|null $navigationIcon = 'lucide-flag'; - protected static ?string $recordTitleAttribute = 'name'; - protected static ?string $cluster = AdministratorCluster::class; protected static string|\UnitEnum|null $navigationGroup = 'Static Data'; diff --git a/app/Filament/Resources/Events/EventResource.php b/app/Filament/Resources/Events/EventResource.php index a1821cef..cce8cdba 100644 --- a/app/Filament/Resources/Events/EventResource.php +++ b/app/Filament/Resources/Events/EventResource.php @@ -10,7 +10,9 @@ use Carbon\Carbon; use Filament\Resources\Resource; use Filament\Schemas\Schema; use Filament\Tables\Table; +use Illuminate\Contracts\Support\Htmlable; use Illuminate\Database\Eloquent\Builder; +use Illuminate\Database\Eloquent\Model; class EventResource extends Resource { @@ -22,10 +24,31 @@ class EventResource extends Resource protected static ?string $modelLabel = ''; - protected static ?string $title = ''; + protected static ?string $title = 'Monitor'; protected static ?string $pluralModelLabel = ''; + // protected static ?string $recordTitleAttribute = 'tx_id'; + // public static function getGlobalSearchResultTitle(Model $record): string|Htmlable + // { + // return $record->home->name.' - '.$record->away->name; + // } + // public static function getGlobalSearchResultDetails(Model $record): array + // { + // return [ + // 'League' => $record->competition_group->name, + // 'Country' => $record->country->name, + // ]; + // } + // public static function getGloballySearchableAttributes(): array + // { + // return ['tx_id', 'betradar_id', 'competition_group.name', 'country.name', 'away.name', 'home.name']; + // } + // public static function getGlobalSearchResultUrl(Symbol|Model $record): string + // { + // return EventResource::getUrl('edit', ['record' => $record]); // Links to the edit page + // } + public static function form(Schema $schema): Schema { return EventForm::configure($schema); diff --git a/app/Filament/Resources/Events/Tables/EventsTable.php b/app/Filament/Resources/Events/Tables/EventsTable.php index 87e9e2af..8f7857a1 100644 --- a/app/Filament/Resources/Events/Tables/EventsTable.php +++ b/app/Filament/Resources/Events/Tables/EventsTable.php @@ -3,19 +3,24 @@ namespace App\Filament\Resources\Events\Tables; use App\Filament\Tables\Columns\MultilineColumn; +use App\Models\CompetitionGroup; +use App\Models\Country; use App\Models\Event; use Carbon\Carbon; use Filament\Actions\Action; use Filament\Actions\ActionGroup; use Filament\Actions\DeleteAction; use Filament\Actions\EditAction; +use Filament\Forms\Components\Select; +use Filament\Schemas\Components\Utilities\Get; use Filament\Support\Enums\FontWeight; use Filament\Support\Enums\IconSize; use Filament\Tables\Columns\IconColumn; use Filament\Tables\Columns\TextColumn; use Filament\Tables\Enums\FiltersLayout; -use Filament\Tables\Filters\SelectFilter; +use Filament\Tables\Filters\Filter; use Filament\Tables\Table; +use Illuminate\Database\Eloquent\Builder; class EventsTable { @@ -30,7 +35,11 @@ class EventsTable ->size(IconSize::ExtraLarge) ->icon(fn ($record) => $record->sport->icon) ->tooltip(fn ($record) => $record->id), - TextColumn::make('tx_id')->label('Id')->badge()->copyable()->searchable(), + TextColumn::make('tx_id') + ->label('Id') + ->badge() + ->searchable() + ->copyable(), TextColumn::make('starttime') ->label('Start') ->alignCenter() @@ -38,40 +47,88 @@ class EventsTable ->weight(FontWeight::Bold) ->description(fn ($state): string => Carbon::createFromDate($state)->format('H:i')), TextColumn::make('country.name') + ->searchable() ->color('gray') ->label('Event') ->icon(fn ($record) => $record->country->icon) ->description(fn ($record) => $record->competition_group->name), - TextColumn::make('home.name')->alignRight()->searchable(), - TextColumn::make('away.name')->searchable(), - - MultilineColumn::make('id') + TextColumn::make('home.name') ->searchable() - ->label(fn () => view('filament.tables.columns.multiline.label')), - + ->alignRight(), + TextColumn::make('away.name') + ->searchable(), + MultilineColumn::make('id')->label(fn () => view('filament.tables.columns.multiline.label')), ]) ->poll('10s') ->defaultSort('starttime', 'ASC') ->filters([ - SelectFilter::make('competition_group_id') - ->preload() - ->label('League') - ->multiple() - ->searchable() - ->options(function () { + Filter::make('events') + ->schema([ + Select::make('country_id') + ->label('Country') + ->searchable() + ->preload() + ->options(function () { + $res = Event::query()->where('starttime', '>', Carbon::now())->groupBy('country_id')->pluck('country_id')->toArray(); - $res = Event::with('country')->with('competition_group')->where('starttime', '>', Carbon::now())->groupBy('competition_group_id')->get(); - $arr = []; - foreach ($res as $val) { - $arr[$val->competition_group_id] = $val->country->name.' - '.$val->competition_group->name; - } + return Country::query()->whereIn('tx_id', $res)->pluck('name', 'tx_id'); + }) + ->live() + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('competition_group_id', null); + }), + Select::make('competition_group_id') + ->label('League') + ->multiple() + ->columnSpan(2) + ->searchable() + ->options(function (Get $get) { + if ($get('country_id')) { + $res = Event::with('country')->with('competition_group')->where('country_id', $get('country_id'))->where('starttime', '>', Carbon::now())->groupBy('competition_group_id')->get(); + } else { + $res = Event::with('country')->with('competition_group')->where('starttime', '>', Carbon::now())->groupBy('competition_group_id')->get(); + } + $arr = []; + foreach ($res as $val) { + $arr[$val->competition_group_id] = $val->country->name.' - '.$val->competition_group->name; + } + asort($arr); - asort($arr); + return $arr; + }) + ->live(), + ]) + // ->indicateUsing(function (array $data): array { + // $indicators = []; - return $arr; + // if ($data['country_id'] ?? null) { + // $indicators[] = 'Country: '.Country::where('tx_id', $data['country_id'])->pluck('name')->first(); + // } + + // if ($data['competition_group_id'] ?? null) { + // if (is_array($data['competition_group_id'])) { + // foreach ($data['competition_group_id'] as $competition_group_id) { + // $indicators[] = 'League: '.CompetitionGroup::where('tx_id', $competition_group_id)->pluck('name')->first(); + // } + // } else { + // $indicators[] = 'League: '.CompetitionGroup::where('tx_id', $data['competition_group_id'])->pluck('name')->first(); + // } + // } + + // return $indicators; + // }) + ->query(function (Builder $query, array $data): Builder { + return $query + ->when( + $data['country_id'], + fn (Builder $query, $sport_id) => $query->where('country_id', $sport_id) + )->when( + $data['competition_group_id'], + fn (Builder $query, $competition_group_id) => $query->where('competition_group_id', $competition_group_id) + ); }) - ->columnSpan(2) - ->selectablePlaceholder(false), + ->columns(6)->columnSpan(6), ], layout: FiltersLayout::AboveContent) ->filtersFormColumns(6) ->deferFilters(false) diff --git a/app/Filament/Resources/MultilineClients/Tables/MultilineClientsTable.php b/app/Filament/Resources/MultilineClients/Tables/MultilineClientsTable.php index 988179ce..883f9b44 100644 --- a/app/Filament/Resources/MultilineClients/Tables/MultilineClientsTable.php +++ b/app/Filament/Resources/MultilineClients/Tables/MultilineClientsTable.php @@ -57,7 +57,7 @@ class MultilineClientsTable ->deferFilters(false) ->filters([ Filter::make('multiline') - ->form([ + ->schema([ Select::make('sport_id') ->label('Sport') ->default(1) diff --git a/app/Livewire/ClientSwitch.php b/app/Livewire/ClientSwitch.php deleted file mode 100644 index 5339e211..00000000 --- a/app/Livewire/ClientSwitch.php +++ /dev/null @@ -1,33 +0,0 @@ -clients = Client::pluck('name', 'id')->all(); - - $this->client = Client::where('id', auth()->user()->client_id)->pluck('name')->first(); - } - - public function render() - { - return view('livewire.client-switch'); - } - - public function swop($client_id) - { - User::where('id', auth()->user()->id)->update(['client_id' => $client_id]); - - $this->js('window.location.reload()'); - } -} diff --git a/app/Livewire/MonitorBettypeSwitch.php b/app/Livewire/MonitorBettypeSwitch.php index 5b66d632..14dc4cf4 100644 --- a/app/Livewire/MonitorBettypeSwitch.php +++ b/app/Livewire/MonitorBettypeSwitch.php @@ -2,9 +2,7 @@ namespace App\Livewire; -use App\Models\Client; use App\Models\MultilineSetting; -use App\Models\Sport; use App\Models\User; use Livewire\Component; @@ -12,25 +10,8 @@ class MonitorBettypeSwitch extends Component { public $multilines = []; - public $sports = []; - - public $sport_id = 0; - - public $sporticon = ''; - - public $iconcolor = ''; - public function mount() { - $cps = Client::where('id', auth()->user()->client_id)->pluck('sport')->first(); - - $this->sports = Sport::whereIn('id', $cps)->pluck('name', 'id'); - - $this->sporticon = Sport::where('id', auth()->user()->sport_id)->pluck('icon')->first(); - - $this->iconcolor = Sport::where('id', auth()->user()->sport_id)->pluck('color')->first(); - - $this->sport_id = auth()->user()->sport_id; $this->multilines = []; @@ -60,11 +41,4 @@ class MonitorBettypeSwitch extends Component $this->js('window.location.reload()'); } - - public function swopSport() - { - User::where('id', auth()->user()->id)->update(['sport_id' => $this->sport_id]); - - $this->js('window.location.reload()'); - } } diff --git a/app/Livewire/TopMenuItems.php b/app/Livewire/TopMenuItems.php new file mode 100644 index 00000000..640c1526 --- /dev/null +++ b/app/Livewire/TopMenuItems.php @@ -0,0 +1,64 @@ +user()->client_id)->pluck('sport')->first(); + + $this->sports = Sport::whereIn('id', $cps)->pluck('name', 'id'); + + $this->sporticon = Sport::where('id', auth()->user()->sport_id)->pluck('icon')->first(); + + $this->iconcolor = Sport::where('id', auth()->user()->sport_id)->pluck('color')->first(); + + $this->sport_id = auth()->user()->sport_id; + + $this->clients = Client::pluck('name', 'id')->all(); + + $this->client = Client::where('id', auth()->user()->client_id)->pluck('name')->first(); + + $this->current = Route::currentRouteName(); + } + + public function render() + { + return view('livewire.top-menu-items'); + } + + public function swop($client_id) + { + User::where('id', auth()->user()->id)->update(['client_id' => $client_id]); + + $this->js('window.location.reload()'); + } + + public function swopSport() + { + User::where('id', auth()->user()->id)->update(['sport_id' => $this->sport_id]); + + $this->js('window.location.reload()'); + } +} diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 12f377ae..c1074884 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -42,7 +42,7 @@ class AppServiceProvider extends ServiceProvider FilamentView::registerRenderHook( PanelsRenderHook::GLOBAL_SEARCH_BEFORE, - fn (): string => Blade::render('@livewire(\'client-switch\')') + fn (): string => Blade::render('@livewire(\'top-menu-items\')') // fn (): string => auth()->user()->hasRole('konto_switch') ? Blade::render('@livewire(\'konto-switch\')') : false ); diff --git a/app/Providers/Filament/AdminPanelProvider.php b/app/Providers/Filament/AdminPanelProvider.php index ad5a7aee..c4cc1c5b 100644 --- a/app/Providers/Filament/AdminPanelProvider.php +++ b/app/Providers/Filament/AdminPanelProvider.php @@ -2,6 +2,7 @@ namespace App\Providers\Filament; +use Agencetwogether\HooksHelper\HooksHelperPlugin; use Awcodes\LightSwitch\Enums\Alignment; use Awcodes\LightSwitch\LightSwitchPlugin; use Filament\Actions\Action; @@ -44,6 +45,8 @@ class AdminPanelProvider extends PanelProvider ->databaseNotifications() ->profile(isSimple: false) ->default() + ->globalSearch(false) + ->globalSearchKeyBindings(['command+k', 'ctrl+k']) ->brandLogo(asset('images/nuh-odds.svg')) ->darkModeBrandLogo(asset('images/nuh-odds-d.svg')) ->favicon(asset('images/nuh.svg')) @@ -91,6 +94,7 @@ class AdminPanelProvider extends PanelProvider ->authMiddleware([ Authenticate::class, ])->plugins([ + HooksHelperPlugin::make(), FilamentEditProfilePlugin::make()->shouldRegisterNavigation(false), LightSwitchPlugin::make()->position(Alignment::BottomCenter), FilamentBackgroundsPlugin::make() diff --git a/composer.json b/composer.json index 056de4eb..09e7d3ba 100644 --- a/composer.json +++ b/composer.json @@ -10,6 +10,7 @@ "license": "MIT", "require": { "php": "^8.3", + "agencetwogether/hookshelper": "^0.0.3", "awcodes/light-switch": "^2.0", "codeat3/blade-phosphor-icons": "^2.0", "codewithdennis/filament-lucide-icons": "*", diff --git a/composer.lock b/composer.lock index 4fea3172..7425e008 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,81 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "45deaaab620ed1b3c5cfc7c74d900c94", + "content-hash": "c75c2edc61fdc14a9f9af425bf74c8a0", "packages": [ + { + "name": "agencetwogether/hookshelper", + "version": "0.0.3", + "source": { + "type": "git", + "url": "https://github.com/agencetwogether/hooksHelper.git", + "reference": "18233250c85e544e91a93c73b3b120a9f64b54a1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/agencetwogether/hooksHelper/zipball/18233250c85e544e91a93c73b3b120a9f64b54a1", + "reference": "18233250c85e544e91a93c73b3b120a9f64b54a1", + "shasum": "" + }, + "require": { + "filament/filament": "^3.0|^4.0", + "php": "^8.1", + "spatie/laravel-package-tools": "^1.15.0" + }, + "require-dev": { + "laravel/pint": "^1.0", + "nunomaduro/collision": "^7.9", + "orchestra/testbench": "^8.0", + "pestphp/pest": "^2.1", + "pestphp/pest-plugin-arch": "^2.0", + "pestphp/pest-plugin-laravel": "^2.0" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Agencetwogether\\HooksHelper\\HooksHelperServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "Agencetwogether\\HooksHelper\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Max", + "email": "contact@agencetwogether.fr", + "role": "Developer" + } + ], + "description": "Simple plugin to toggle display hooks available in current page.", + "homepage": "https://github.com/agencetwogether/hookshelper", + "keywords": [ + "agencetwogether", + "filament", + "filamentphp", + "helper", + "hooks", + "laravel" + ], + "support": { + "issues": "https://github.com/agencetwogether/hookshelper/issues", + "source": "https://github.com/agencetwogether/hookshelper" + }, + "funding": [ + { + "url": "https://github.com/agencetwogether", + "type": "github" + } + ], + "time": "2025-09-25T06:57:44+00:00" + }, { "name": "anourvalar/eloquent-serialize", "version": "1.3.5", diff --git a/config/hookshelper.php b/config/hookshelper.php new file mode 100644 index 00000000..6dd6359a --- /dev/null +++ b/config/hookshelper.php @@ -0,0 +1,32 @@ + 'global-search.before', + /* + |-------------------------------------------------------------------------- + | Icon + |-------------------------------------------------------------------------- + | You may select a different Heroicon to display for the hooks visibility + | toggle button. If null, the default will be 'heroicon-m-cursor-arrow-rays'. + | + */ + 'icon' => 'heroicon-m-cursor-arrow-rays', + /* + |-------------------------------------------------------------------------- + | Minify Button + |-------------------------------------------------------------------------- + | Setting this to true will only display a small icon as a toggle button. + | Otherwise, the button will display action label to perform. + | + */ + 'tiny_toggle' => true, +]; diff --git a/package-lock.json b/package-lock.json index 431f237c..e5691fcf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1990,7 +1990,6 @@ "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=12" }, @@ -2224,7 +2223,6 @@ "integrity": "sha512-dZwN5L1VlUBewiP6H9s2+B3e3Jg96D0vzN+Ry73sOefebhYr9f94wwkMNN/9ouoU8pV1BqA1d1zGk8928cx0rg==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "esbuild": "^0.27.0", "fdir": "^6.5.0", diff --git a/resources/views/livewire/client-switch.blade.php b/resources/views/livewire/client-switch.blade.php deleted file mode 100644 index 7535b185..00000000 --- a/resources/views/livewire/client-switch.blade.php +++ /dev/null @@ -1,15 +0,0 @@ - - - - {{ $client }} - - - - - @foreach ($clients as $id => $name) - - {{ $name }} - - @endforeach - - diff --git a/resources/views/livewire/monitor-bettype-switch.blade.php b/resources/views/livewire/monitor-bettype-switch.blade.php index fa01d4b0..a425f8ea 100644 --- a/resources/views/livewire/monitor-bettype-switch.blade.php +++ b/resources/views/livewire/monitor-bettype-switch.blade.php @@ -1,42 +1,6 @@ -
- - - - Mapper - - - - - Event Mapper - - - {{-- Modal content --}} -
-
- @livewire('mapper-events') -
-
- @livewire('mapper-clients') -
-
- -
-
- - - - @foreach ($sports as $id => $name) - - @endforeach - - - - - - {{-- protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedSquares2x2; --}} +
@foreach ($multilines as $multiline) -
@if ($multiline['is_active'] == 1) {{ $multiline['short'] }} diff --git a/resources/views/livewire/top-menu-items.blade.php b/resources/views/livewire/top-menu-items.blade.php new file mode 100644 index 00000000..7ea40f30 --- /dev/null +++ b/resources/views/livewire/top-menu-items.blade.php @@ -0,0 +1,51 @@ +
+ @if ($this->current == 'filament.admin.resources.events.index') + + + @foreach ($sports as $id => $name) + + @endforeach + + + + + + + Event Mapper + + + + + Event Mapper + + + {{-- Modal content --}} +
+
+ @livewire('mapper-events') +
+
+ @livewire('mapper-clients') +
+
+ +
+ @endif + + + + + {{ $client }} + + + + + @foreach ($clients as $id => $name) + + {{ $name }} + + @endforeach + + + +