wip filter

This commit is contained in:
salam committed 2026-01-10 13:17:09 +01:00
1 parent c4d7f2e6ee
commit d2caac4bcc
20 files changed
+567 -119

No files matched your search

@@ -17,7 +17,7 @@ class ClientResource extends Resource
protected static ?int $navigationSort = 32;
protected static string|\BackedEnum|null $navigationIcon = 'lucide-square-user';
protected static string|\BackedEnum|null $navigationIcon = 'phosphor-baseball-helmet';
protected static ?string $cluster = AdministratorCluster::class;
@@ -3,6 +3,7 @@
namespace App\Filament\Resources\Events\Tables;
use App\Filament\Tables\Columns\Column3way;
use App\Filament\Tables\Columns\Column3wayHt;
use App\Filament\Tables\Columns\ColumnDc;
use App\Filament\Tables\Columns\ColumnDnb;
use App\Filament\Tables\Columns\ColumnGgng;
@@ -11,6 +12,7 @@ use App\Filament\Tables\Columns\ColumnMlS1;
use App\Filament\Tables\Columns\ColumnPoint;
use App\Filament\Tables\Columns\ColumnPointQ1;
use App\Filament\Tables\Columns\ColumnTotal;
use App\Filament\Tables\Columns\ColumnTotalHt;
use App\Filament\Tables\Columns\ColumnTotalQ1;
use App\Filament\Tables\Columns\ColumnTq;
use App\Filament\Tables\Columns\MatchIds;
@@ -47,7 +49,12 @@ class EventsTable
public static function load_multiline_bookmaker()
{
$res = MultilineClient::with('multiline_setting')->where('client_id', auth()->user()->client_id)->where('sport_id', auth()->user()->sport_id)->select('bookmaker_id', 'multiline_setting_id')->orderBy('multiline_setting_id')->orderBy('sort')->get();
$res = MultilineClient::with('multiline_setting')
->where('client_id', auth()->user()->client_id)
->where('sport_id', auth()->user()->sport_id)
->select('bookmaker_id', 'multiline_setting_id')
->orderBy('sort')
->get();
foreach ($res as $value) {
self::$multiline_gettype[$value->multiline_setting->table][] = $value->bookmaker_id;
@@ -56,7 +63,10 @@ class EventsTable
public static function load_bettype_settings()
{
$res = BettypeUser::with('multiline_setting')->where('is_active', 1)->get();
$res = BettypeUser::with('multiline_setting')
->orderBy('multiline_setting_id')
->where('is_active', 1)
->get();
foreach ($res as $value) {
self::$bettype_settings[] = $value->multiline_setting->table;
@@ -107,6 +117,7 @@ class EventsTable
TextColumn::make('away.name')
->wrap()
->searchable(),
ColumnMl::make('odds_2ways')->bookmakers(self::$multiline_gettype['odds_2ways'] ?? [])
->visible(fn () => in_array('odds_2ways', self::$bettype_settings))
->verticalAlignment(VerticalAlignment::Start)
@@ -125,8 +136,16 @@ class EventsTable
->visible(fn () => in_array('odds_3ways', self::$bettype_settings))
->verticalAlignment(VerticalAlignment::Start)
->width(225)
->alignCenter()
->label('1X2'),
Column3wayHt::make('odds_3ways_ht')->bookmakers(self::$multiline_gettype['odds_3ways_ht'] ?? [])
->visible(fn () => in_array('odds_3ways_ht', self::$bettype_settings))
->verticalAlignment(VerticalAlignment::Start)
->alignCenter()
->width(225)
->label('1X2 HT'),
ColumnTotal::make('odds_totals')->bookmakers(self::$multiline_gettype['odds_totals'] ?? [])
->visible(fn () => in_array('odds_totals', self::$bettype_settings))
->verticalAlignment(VerticalAlignment::Start)
@@ -134,6 +153,13 @@ class EventsTable
->width(225)
->label('Totals'),
ColumnTotalHt::make('odds_totals_ht')->bookmakers(self::$multiline_gettype['odds_totals_ht'] ?? [])
->visible(fn () => in_array('odds_totals_ht', self::$bettype_settings))
->verticalAlignment(VerticalAlignment::Start)
->alignCenter()
->width(225)
->label('Totals HT'),
ColumnTotalQ1::make('odds_totals_q1')->bookmakers(self::$multiline_gettype['odds_totals_q1'] ?? [])
->visible(fn () => in_array('odds_totals_q1', self::$bettype_settings))
->verticalAlignment(VerticalAlignment::Start)
@@ -191,7 +217,7 @@ class EventsTable
->schema([
Select::make(name: 'country_id')
->placeholder('Country')
->columnSpan(2)
->columnSpan(4)
->hiddenLabel()
->label('')
->searchable()
@@ -211,7 +237,7 @@ class EventsTable
->hiddenLabel()
->label('')
->multiple()
->columnSpan(3)
->columnSpan(6)
->searchable()
->options(function (Get $get) {
if ($get('country_id')) {
@@ -229,7 +255,7 @@ class EventsTable
})
->live(),
DateRangePicker::make('starttime_period')
->columnSpan(4)
->columnSpan(8)
->startPrefix('From')
->displayFormat('d M Y')
->minDate(now())
@@ -279,7 +305,7 @@ class EventsTable
}
);
})
->columns(12)->columnSpan(12),
->columns(19)->columnSpan(19),
], layout: FiltersLayout::AboveContent)
->filtersFormColumns(6)
->deferFilters(false)
@@ -0,0 +1,73 @@
<?php
namespace App\Filament\Tables\Columns;
use Filament\Tables\Columns\Column;
class Column3wayHt extends Column
{
protected string $view = 'filament.tables.columns.column_3way_ht';
protected ?array $bookmakers;
protected $max;
protected $min;
protected $act;
protected ?bool $has_data;
public function bookmakers(?array $bookmakers): static
{
array_unshift($bookmakers, auth()->user()->bookmaker_id);
$this->bookmakers = $bookmakers;
return $this;
}
public function getBookmaker(): ?array
{
return $this->bookmakers;
}
public function loadData($record)
{
$this->has_data = count($record->odds_3ways_ht) ? true : false;
$this->act = $record->odds_3ways_ht->where('bookmaker_id', auth()->user()->bookmaker_id)->first();
$this->max['h3w'] = $record->odds_3ways_ht->max('h3w');
$this->max['d3w'] = $record->odds_3ways_ht->max('d3w');
$this->max['a3w'] = $record->odds_3ways_ht->max('a3w');
$this->min['h3w'] = $record->odds_3ways_ht->min('h3w');
$this->min['d3w'] = $record->odds_3ways_ht->min('d3w');
$this->min['a3w'] = $record->odds_3ways_ht->min('a3w');
}
public function getAct()
{
return $this->act;
}
public function getMax()
{
return $this->max;
}
public function getMin()
{
return $this->min;
}
public function hasData()
{
return $this->has_data;
}
}
@@ -0,0 +1,70 @@
<?php
namespace App\Filament\Tables\Columns;
use Filament\Tables\Columns\Column;
class ColumnTotalHt extends Column
{
protected string $view = 'filament.tables.columns.column-total-ht';
protected ?array $bookmakers;
protected $max;
protected $min;
protected $act;
protected ?bool $has_data;
public function bookmakers(?array $bookmakers): static
{
array_unshift($bookmakers, auth()->user()->bookmaker_id);
$this->bookmakers = $bookmakers;
return $this;
}
public function getBookmaker(): ?array
{
return $this->bookmakers;
}
public function loadData($record)
{
$this->has_data = count($record->odds_totals_ht) ? true : false;
$this->act = $record->odds_totals_ht->where('bookmaker_id', auth()->user()->bookmaker_id)->first();
$this->max['over'] = $record->odds_totals_ht->max('over');
$this->max['under'] = $record->odds_totals_ht->max('under');
$this->min['over'] = $record->odds_totals_ht->min('over');
$this->min['under'] = $record->odds_totals_ht->min('under');
}
public function getAct()
{
return $this->act;
}
public function getMax()
{
return $this->max;
}
public function getMin()
{
return $this->min;
}
public function hasData()
{
return $this->has_data;
}
}
+7 -4
View File
@@ -8,7 +8,7 @@ use Livewire\Component;
class BettypeToggle extends Component
{
public $multilines = [];
public $bettype_toggles = [];
protected $listeners = [
'refreshBettypeMenu' => '$refresh',
@@ -16,15 +16,18 @@ class BettypeToggle extends Component
public function boot()
{
$this->multilines = [];
$this->bettype_toggles = [];
$res = BettypeUser::with('multiline_setting')->get();
$res = BettypeUser::with('multiline_setting')
->orderBy('multiline_setting_id')
->get();
foreach ($res as $set) {
$this->multilines[] = [
$this->bettype_toggles[] = [
'id' => $set->multiline_setting_id,
'name' => $set->multiline_setting->name,
'short' => $set->multiline_setting->short,
'matchpart' => $set->multiline_setting->matchpart,
'is_active' => $set->is_active,
];
}
+37
View File
@@ -0,0 +1,37 @@
<?php
namespace App\Livewire;
use App\Models\Client;
use App\Models\User;
use Livewire\Component;
class KontoSwitcher extends Component
{
public $clients = [];
public function mount()
{
$this->clients = Client::where('id', '!=', auth()->user()->client_id)->pluck('name', 'id')->all();
}
public function swopClient($client_id)
{
$providers = Client::where('id', $client_id)->pluck('provider')->first();
$provider_id = array_shift($providers);
$bookmakers = Client::where('id', $client_id)->pluck('bookmaker')->first();
$bookmaker_id = array_shift($bookmakers);
User::where('id', auth()->user()->id)->update(['sport_id' => 1, 'provider_id' => $provider_id, 'bookmaker_id' => $bookmaker_id, 'client_id' => $client_id]);
$this->js('window.location.reload()');
}
public function render()
{
return view('livewire.konto-switcher');
}
}
+47
View File
@@ -0,0 +1,47 @@
<?php
namespace App\Livewire;
use App\Models\Client;
use App\Models\Sport;
use App\Models\User;
use Livewire\Component;
class SportSwitcher extends Component
{
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;
}
public function swopSport()
{
User::where('id', auth()->user()->id)->update(['sport_id' => $this->sport_id]);
$this->dispatch('clear_filters');
$this->js('window.location.reload()');
}
public function render()
{
return view('livewire.sport-switcher');
}
}
-50
View File
@@ -2,26 +2,12 @@
namespace App\Livewire;
use App\Models\Client;
use App\Models\Sport;
use App\Models\User;
use Illuminate\Support\Facades\Route;
use Livewire\Component;
class TopMenuItems extends Component
{
public $clients = [];
public ?string $client = '';
public $sports = [];
public $sport_id = 0;
public $sporticon = '';
public $iconcolor = '';
public $current = '';
protected $listeners = [
@@ -31,20 +17,6 @@ class TopMenuItems extends Component
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->clients = Client::pluck('name', 'id')->all();
$this->client = Client::where('id', auth()->user()->client_id)->pluck('name')->first();
$this->current = Route::currentRouteName();
}
@@ -53,21 +25,6 @@ class TopMenuItems extends Component
return view('livewire.top-menu-items');
}
public function swop($client_id)
{
$providers = Client::where('id', $client_id)->pluck('provider')->first();
$provider_id = array_shift($providers);
$bookmakers = Client::where('id', $client_id)->pluck('bookmaker')->first();
$bookmaker_id = array_shift($bookmakers);
User::where('id', auth()->user()->id)->update(['sport_id' => 1, 'provider_id' => $provider_id, 'bookmaker_id' => $bookmaker_id, 'client_id' => $client_id]);
$this->js('window.location.reload()');
}
public function swopBookmaker($bookmaker_id)
{
User::where('id', auth()->user()->id)->update(['bookmaker_id' => $bookmaker_id]);
@@ -81,11 +38,4 @@ class TopMenuItems extends Component
$this->dispatch('reload_data_right');
}
public function swopSport()
{
User::where('id', auth()->user()->id)->update(['sport_id' => $this->sport_id]);
$this->js('window.location.reload()');
}
}
+12 -2
View File
@@ -28,6 +28,17 @@ class AppServiceProvider extends ServiceProvider
*/
public function boot(): void
{
FilamentView::registerRenderHook(
PanelsRenderHook::USER_MENU_PROFILE_AFTER,
fn (): string => Blade::render('@livewire(\'konto-switcher\')'),
);
FilamentView::registerRenderHook(
TablesRenderHook::TOOLBAR_SEARCH_BEFORE,
fn (): string => Blade::render('@livewire(\'sport-switcher\')'),
scopes: [
ListEvents::class,
]
);
FilamentView::registerRenderHook(
TablesRenderHook::TOOLBAR_SEARCH_AFTER,
fn (): string => Blade::render('@livewire(\'bettype-toggle\')'),
@@ -35,9 +46,8 @@ class AppServiceProvider extends ServiceProvider
ListEvents::class,
]
);
// GLOBAL_SEARCH_BEFORE
FilamentView::registerRenderHook(
PanelsRenderHook::TOPBAR_LOGO_AFTER,
PanelsRenderHook::GLOBAL_SEARCH_BEFORE,
fn (): string => Blade::render('@livewire(\'top-menu-items\')')
// fn (): string => auth()->user()->hasRole('konto_switch') ? Blade::render('@livewire(\'konto-switch\')') : false
);
@@ -3,9 +3,9 @@
namespace App\Providers\Filament;
use Agencetwogether\HooksHelper\HooksHelperPlugin;
use BezhanSalleh\FilamentShield\FilamentShieldPlugin;
use Awcodes\LightSwitch\Enums\Alignment;
use Awcodes\LightSwitch\LightSwitchPlugin;
use BezhanSalleh\FilamentShield\FilamentShieldPlugin;
use Filament\Actions\Action;
use Filament\Auth\MultiFactor\App\AppAuthentication;
use Filament\Auth\MultiFactor\Email\EmailAuthentication;