filter finised

This commit is contained in:
salam committed 2026-02-02 18:33:32 +01:00
1 parent ff43f231f0
commit f684d61a61
15 files changed
+376 -136

No files matched your search

@@ -39,25 +39,18 @@ class ListEvents extends ListRecords
public function updateStar(): void
{
// $filters = $this->table->getFilters();
$filters = $this->getTable()->getFilters();
dd($filters['filter_stars']->getState());
$filter_stars = $filters['filter_stars']->getState();
$this->tableFilters['events']['filter_stars'] = ! $filter_stars;
$this->tableFilters['events']['filter_stars'] = ! $this->tableFilters['events']['filter_stars'];
}
// public function updateNote(): void
// {
// $this->tableFilters['events']['filter_notes'] = auth()->user()->filter_notes;
// }
public function updateNote(): void
{
$this->tableFilters['events']['filter_notes'] = ! $this->tableFilters['events']['filter_notes'];
}
// public function updateNotification(): void
// {
// $this->tableFilters['events']['filter_notification'] = auth()->user()->filter_notification;
// }
public function updateNotification(): void
{
$this->tableFilters['events']['filter_notification'] = ! $this->tableFilters['events']['filter_notification'];
}
public function updateTablePeriode(string $filter): void
{
@@ -26,8 +26,8 @@ use Filament\Actions\BulkActionGroup;
use Filament\Actions\DeleteAction;
use Filament\Actions\DeleteBulkAction;
use Filament\Forms\Components\Hidden;
use Filament\Forms\Components\Radio;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Toggle;
use Filament\Schemas\Components\Utilities\Get;
@@ -43,6 +43,7 @@ use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\DB;
use JaOcero\RadioDeck\Forms\Components\RadioDeck;
class EventsTable
{
@@ -105,7 +106,8 @@ class EventsTable
->label('ML S1'),
TooltipOdds::make('1x2')->bettype('odds_3ways')->label('')->visible(fn () => in_array('odds_3ways', self::$bettype_settings)),
ColumnOdds::make('odds_3ways')->bettype('odds_3ways')
ColumnOdds::make('odds_3ways')
->bettype('odds_3ways')
->visible(fn () => in_array('odds_3ways', self::$bettype_settings))
->verticalAlignment(VerticalAlignment::Start)
->label('1X2'),
@@ -446,15 +448,15 @@ class EventsTable
}
if ($data['filter_stars'] ?? null) {
$indicators[] = Indicator::make('Filter Favorits')->removeField('filter_stars')->color('success');
$indicators[] = Indicator::make('Filter Favorits')->removeField('filter_stars')->color('info');
}
if ($data['filter_notes'] ?? null) {
$indicators[] = Indicator::make('Filter Notes')->removeField('filter_notes')->color('success');
$indicators[] = Indicator::make('Filter Notes')->removeField('filter_notes')->color('info');
}
if ($data['filter_notification'] ?? null) {
$indicators[] = Indicator::make('Filter Notifications')->removeField('filter_notification')->color('success');
$indicators[] = Indicator::make('Filter Notifications')->removeField('filter_notification')->color('info');
}
if ($data['filter_alarm_green'] ?? null) {
@@ -513,10 +515,6 @@ class EventsTable
}
}
// 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']);
$title = $opt[0];
@@ -577,9 +575,7 @@ class EventsTable
->modalIcon('phosphor-note')
->modalWidth(Width::Large)
->modalSubmitActionLabel('Save')
->extraModalFooterActions(fn (Action $action): array => [
$action->makeModalSubmitAction('Delete', arguments: ['delete' => true])->color('danger'),
])
->extraModalFooterActions(fn (Action $action, $record) => $record->event_user_note->isEmpty() ? [] : [$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) {
@@ -594,14 +590,17 @@ class EventsTable
})
->schema([
Hidden::make('event_user_note_id'),
TextInput::make('message')->prefixIcon('phosphor-note-pencil')->hiddenLabel()->live()
->extraInputAttributes(['onClick' => 'this.select()']),
Textarea::make('message')
->rows(2)
->hiddenLabel(),
])
->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']) {
->action(function ($record, array $data, $arguments = []) {
if ($arguments) {
EventUserNote::where('id', $data['event_user_note_id'])->delete();
} elseif ($data['event_user_note_id']) {
if (! $data['message']) {
EventUserNote::where('id', $data['event_user_note_id'])->delete();
} else {
@@ -622,9 +621,7 @@ class EventsTable
Action::make('event_notification')
->modalWidth(Width::Large)
->modalSubmitActionLabel('Save')
->extraModalFooterActions(fn (Action $action): array => [
$action->makeModalSubmitAction('Delete', arguments: ['delete' => true])->color('danger'),
])
->extraModalFooterActions(fn (Action $action, $record) => $record->event_user_notification->isEmpty() ? [] : [$action->makeModalSubmitAction('Delete', arguments: ['delete' => true])->color('danger')])
->modalIcon('phosphor-bell')
->fillForm(data: function ($record) {
foreach ($record->event_user_notification as $value) {
@@ -643,36 +640,44 @@ class EventsTable
})
->schema([
Hidden::make('event_user_notification_id'),
Toggle::make('is_notified')->label('Monitoring')
->aboveContent('If a notification has been send "Monitoring" will be off')
Toggle::make('is_notified')->label('Monitoring Favorit')
// ->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')
RadioDeck::make('odds_table_id')
->label('Bettype')
->columns(3)
->colors('info')
->required()
->prefixIcon('phosphor-dots-three-outline-vertical')
->native(false)
->extraCardsAttributes([ // Extra attributes for card elements
'class' => 'dark:bg-gray-900!',
])
->options(fn ($record) => OddsTable::options_sport()),
Radio::make('alarm_level_id')
RadioDeck::make('alarm_level_id')
->label('Alarm level')
->colors('info')
->columns(3)
->required()
->inline()
->belowContent('If favorit enters alarm level a notification will be send.')
->extraCardsAttributes([ // Extra attributes for card elements
'class' => 'dark:bg-gray-900!',
])
->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')
Toggle::make('notify_by_email')->label('Send also 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']) {
->color(fn ($record) => $record?->event_user_notification->isEmpty() ? 'gray' : 'info')
->action(function ($record, array $data, $arguments = []) {
if ($arguments) {
EventUserNotification::where('id', $data['event_user_notification_id'])->delete();
} elseif ($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'],
@@ -691,8 +696,7 @@ class EventsTable
'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')
@@ -28,6 +28,12 @@ class ColumnOdds extends Column
protected $client;
protected $filter_compare_bookmaker;
protected $filter_compare_mode;
protected $favorits = [];
public $compare;
public $partner;
@@ -42,6 +48,18 @@ class ColumnOdds extends Column
{
$this->getData($record);
$this->setCompareDifferences();
$this->favorits = ['h2w' => 0, 'a2w' => 0, 'h3w' => 0, 'd3w' => 0, 'a3w' => 0, 'home' => 0, 'away' => 0, 'margin' => 0];
if ($this->filter_compare_bookmaker) {
if ($this->filter_compare_mode == 'Favorit') {
$this->setFavorits($record);
} elseif ($this->filter_compare_mode == 'X') {
$this->favorits = ['h2w' => 0, 'a2w' => 0, 'h3w' => 0, 'd3w' => 1, 'a3w' => 0, 'home' => 0, 'away' => 0, 'margin' => 0];
} elseif ($this->filter_compare_mode == 'Margin') {
$this->favorits = ['h2w' => 0, 'a2w' => 0, 'h3w' => 0, 'd3w' => 0, 'a3w' => 0, 'home' => 0, 'away' => 0, 'margin' => 1];
}
}
if (! $this->data) {
$this->state = false;
@@ -74,10 +92,31 @@ class ColumnOdds extends Column
return $this;
}
public function setCompareDifferences()
{
$filters = $this->getTable()->getFilters();
$filters = [$filters];
foreach ($filters as $value) {
$filter = $value['events']->getState();
}
if (isset($filter['filter_compare_differences'])) {
$tmp = explode('-', $filter['filter_compare_differences']);
$this->filter_compare_bookmaker = (int) $tmp[2];
$this->filter_compare_mode = $tmp[0];
} else {
$this->filter_compare_bookmaker = 0;
}
}
/*******************************
* GETTER
*******************************/
public function getCompareBookmaker()
{
return $this->filter_compare_bookmaker;
}
public function getBettype()
{
return $this->bettype;
@@ -132,6 +171,11 @@ class ColumnOdds extends Column
return $this->min;
}
public function getFavorits()
{
return $this->favorits;
}
public function getData($record)
{
$this->client = null;
@@ -274,6 +318,42 @@ class ColumnOdds extends Column
* SETTER
*******************************/
public function setFavorits($record)
{
if ($this->filter_compare_bookmaker) {
switch ($this->bettype) {
case 'odds_2ways':
$tmp = $record->odds_2ways->where('bookmaker_id', $this->filter_compare_bookmaker)->first();
if ($tmp->h2w < $tmp->a2w) {
$this->favorits['h2w'] = 1;
} else {
$this->favorits['a2w'] = 1;
}
break;
case 'odds_3ways':
$tmp = $record->odds_3ways->where('bookmaker_id', $this->filter_compare_bookmaker)->first();
if ($tmp->h3w < $tmp->d3w && $tmp->h3w < $tmp->a3w) {
$this->favorits['h3w'] = 1;
} elseif ($tmp->d3w < $tmp->a3w) {
$this->favorits['d3w'] = 1;
} else {
$this->favorits['a3w'] = 1;
}
break;
case 'odds_points':
$tmp = $record->odds_points->where('bookmaker_id', $this->filter_compare_bookmaker)->first();
if ($tmp->home < $tmp->away) {
$this->favorits['home'] = 1;
} else {
$this->favorits['away'] = 1;
}
break;
}
}
}
public function setMinMax($record)
{
switch ($this->bettype) {
+9 -12
View File
@@ -16,12 +16,6 @@ class BettypeToggle extends Component
'refreshBettypeMenu' => '$refresh',
];
protected $filter_star = false;
protected $filter_note = false;
protected $filter_notify = false;
public function boot()
{
$this->bettype_toggles = [];
@@ -39,6 +33,12 @@ class BettypeToggle extends Component
'is_active' => $set->is_active,
];
}
// $filters = $livewire->getTable()->getFilters();
// $filters = [$filters];
// foreach ($filters as $value) {
// dd($value['events']->getState());
// }
}
public function render()
@@ -54,20 +54,17 @@ class BettypeToggle extends Component
public function toggleStar()
{
$this->filter_star = ! $this->filter_star;
$this->dispatch('filterStarFilter', ['filter', $this->filter_star]);
$this->dispatch('filterStarFilter');
}
public function toggleNote()
{
User::where('id', auth()->user()->id)->update(['filter_notes' => DB::raw('!filter_notes')]);
$this->dispatch('filterNotificationFilter');
$this->dispatch('filterNoteFilter');
}
public function toggleNotification()
{
User::where('id', auth()->user()->id)->update(['filter_notification' => DB::raw('!filter_notification')]);
$this->dispatch('filterStarFilter');
$this->dispatch('filterNotificationFilter');
}
public function toggleShowPartner()
+12 -2
View File
@@ -17,6 +17,10 @@ class SportSwitcher extends Component
public $iconcolor = '';
protected $listeners = [
'refreshSportSwitcher' => '$refresh',
];
public function mount()
{
$cps = Client::where('id', auth()->user()->client_id)->pluck('sport')->first();
@@ -35,9 +39,15 @@ class SportSwitcher extends Component
{
User::where('id', auth()->user()->id)->update(['sport_id' => $this->sport_id]);
$this->dispatch('clear_filters');
$this->sporticon = Sport::where('id', $this->sport_id)->pluck('icon')->first();
$this->js('window.location.reload()');
$this->iconcolor = Sport::where('id', $this->sport_id)->pluck('color')->first();
// $this->js('window.location.reload()');
$this->dispatch('filterClearFilter');
$this->dispatch('refreshSportSwitcher');
}
public function render()
-3
View File
@@ -34,9 +34,6 @@ class User extends Authenticatable implements FilamentUser, HasAppAuthentication
'app_verified_at',
'client_id',
'sport_id',
'filter_stars',
'filter_notes',
'filter_notification',
'is_multiline_direct',
'all_only_none',
'partner_show',