wip
This commit is contained in:
1 parent
b0a002c7c1
commit
23cf804865
23 files changed
+283
-123
No files matched your search
@@ -16,7 +16,6 @@ use App\Models\Country;
|
||||
use App\Models\Event;
|
||||
use App\Models\EventBookmaker;
|
||||
use App\Models\EventUserNote;
|
||||
use App\Models\EventUserNotification;
|
||||
use App\Models\EventUserStar;
|
||||
use App\Models\Group;
|
||||
use App\Models\OddsTable;
|
||||
@@ -27,11 +26,9 @@ 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;
|
||||
use Filament\Support\Enums\FontWeight;
|
||||
use Filament\Support\Enums\VerticalAlignment;
|
||||
@@ -416,11 +413,6 @@ class EventsTable
|
||||
function (Builder $query, $filter_notes) {
|
||||
$query->whereHas('event_user_note');
|
||||
}
|
||||
)->when(
|
||||
$data['filter_notification'],
|
||||
function (Builder $query, $filter_notification) {
|
||||
$query->whereHas('event_user_notification');
|
||||
}
|
||||
)->when(
|
||||
$data['favorit_threshold'],
|
||||
function (Builder $query, $favorit_threshold) {
|
||||
@@ -664,77 +656,6 @@ class EventsTable
|
||||
}
|
||||
})
|
||||
->color(fn ($record) => $record->event_user_note->isEmpty() ? 'gray' : 'info'),
|
||||
Action::make('event_notification')
|
||||
->modalWidth(Width::Large)
|
||||
->modalDescription('Monitoring favorit and if condition is matchted the system will emit a notification')
|
||||
->modalSubmitActionLabel('Save')
|
||||
->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) {
|
||||
if ($value->user_id == auth()->user()->id && $value->bookmaker_id == auth()->user()->bookmaker_id) {
|
||||
return [
|
||||
'event_user_notification_id' => $value->id,
|
||||
'odds_table_id' => $value->odds_table_id,
|
||||
'alarm_level_id' => $value->alarm_level_id,
|
||||
'is_notified' => $value->is_notified,
|
||||
'notify_by_email' => $value->notify_by_email,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return ['event_user_notification_id' => ''];
|
||||
})
|
||||
->schema([
|
||||
Hidden::make('event_user_notification_id'),
|
||||
Toggle::make('is_notified')->label('On/Off')
|
||||
->onColor('gray')
|
||||
->offColor('info'),
|
||||
Radio::make('odds_table_id')
|
||||
->label('Bettype')
|
||||
->columns(3)
|
||||
->required()
|
||||
->options(fn ($record) => OddsTable::options_sport()),
|
||||
Radio::make('alarm_level_id')
|
||||
->label('Alarm level')
|
||||
->columns(3)
|
||||
->required()
|
||||
->options([
|
||||
'1' => 'Level 1',
|
||||
'2' => 'Level 2',
|
||||
'3' => 'Level 3',
|
||||
]),
|
||||
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()
|
||||
->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'],
|
||||
'notify_by_email' => $data['notify_by_email'],
|
||||
'is_notified' => $data['is_notified'],
|
||||
]);
|
||||
} else {
|
||||
EventUserNotification::updateOrCreate([
|
||||
'event_id' => $record->id,
|
||||
'bookmaker_id' => auth()->user()->bookmaker_id,
|
||||
'user_id' => auth()->user()->id,
|
||||
], [
|
||||
'odds_table_id' => $data['odds_table_id'],
|
||||
'alarm_level_id' => $data['alarm_level_id'],
|
||||
'notify_by_email' => $data['notify_by_email'],
|
||||
'is_notified' => $data['is_notified'],
|
||||
]);
|
||||
}
|
||||
}),
|
||||
ActionGroup::make([
|
||||
DeleteAction::make()->visible(fn () => auth()->user()->hasRole('super_admin')),
|
||||
Action::make('txodds_odds')
|
||||
|
||||
Reference in new issue
Block a user