This commit is contained in:
salam committed 2026-02-06 07:18:53 +01:00
1 parent 23cf804865
commit 4e77862aa7
14 files changed
+113 -49

No files matched your search

@@ -11,7 +11,7 @@ class AlarmSettings
$res = AlarmSetting::where('sport_id', $sport_id)
->where('client_bookmaker_id', $client_bookmaker_id)
->where('disabled', 0)
->select('multiline_setting_id', 'level_id', 'alarm_threshold')
->select('multiline_setting_id', 'alarm_level_id', 'alarm_threshold')
->get();
$arr = [];
@@ -3,6 +3,7 @@
namespace App\Console\Commands\Services\Tasks;
use App\Console\Commands\Nuh;
use App\Models\AlarmLevel;
use App\Models\AlarmSetting;
use App\Models\BettypeUser;
use App\Models\Bookmaker;
@@ -25,6 +26,11 @@ class GenerateSetting
Notice::note('GENERATE DEFAULT SETTING', 'b');
}
$clients = Client::get();
$users = User::get();
$alarm_levels = AlarmLevel::get();
$sports = Sport::getActiveSports();
/**************************************************
* 1) ALARM BOOKMAKER
**************************************************/
@@ -33,10 +39,6 @@ class GenerateSetting
Notice::note('1) ALARM BOOKMAKER', 'p');
}
$alarm_thresholds = [1 => 0.01, 2 => 0.2, 3 => 0.3];
$clients = Client::get();
foreach ($clients as $client) {
foreach ($client->sport as $sport_id) {
@@ -47,11 +49,11 @@ class GenerateSetting
foreach ($multilines as $multiline_id) {
foreach ($alarm_thresholds as $level_id => $alarm_threshold) {
foreach ($alarm_levels as $alarm_level) {
AlarmSetting::firstOrCreate(
['client_bookmaker_id' => $client_bookmaker_id, 'sport_id' => $sport_id, 'multiline_setting_id' => $multiline_id, 'level_id' => $level_id],
['name' => "LEVEL $level_id", 'alarm_threshold' => $alarm_threshold]
['client_bookmaker_id' => $client_bookmaker_id, 'sport_id' => $sport_id, 'multiline_setting_id' => $multiline_id, 'alarm_level_id' => $alarm_level->id],
['alarm_threshold' => $alarm_level->default_threshold]
);
}
}
@@ -69,8 +71,6 @@ class GenerateSetting
$bookmaker_slots = [1 => 6, 2 => 30, 3 => 649, 4 => 126];
$clients = Client::get();
foreach ($clients as $client) {
foreach ($client->sport as $sport_id) {
@@ -101,8 +101,6 @@ class GenerateSetting
Notice::note('3) GENERATOR BETTYPES IM COMPARATORE FOR USERS', 'p');
}
$users = User::get();
foreach ($users as $user) {
$multilines = MultilineSetting::orderBy('sport_id')->pluck('sport_id', 'id');
@@ -126,13 +124,11 @@ class GenerateSetting
Notice::note('4) COMPARING BOOKMAKER', 'p');
}
$res = Client::get();
$bookmakers_soccer = Bookmaker::where('in_soccer', 1)->orderBy('name')->pluck('id')->toArray();
ComparingBookmaker::where('method_id', 1)->where('sport_id', 1)->whereNotIn('bookmaker_id', $bookmakers_soccer)->delete();
foreach ($res as $client) {
foreach ($clients as $client) {
$client_bookmakers = $client->bookmaker;
@@ -159,7 +155,7 @@ class GenerateSetting
ComparingBookmaker::where('method_id', 1)->whereIn('sport_id', $sports)->whereNotIn('bookmaker_id', $bookmakers_other)->delete();
foreach ($res as $client) {
foreach ($clients as $client) {
$client_bookmakers = $client->bookmaker;
@@ -195,16 +191,16 @@ class GenerateSetting
$sports = Client::find($user->client_id)->value('sport');
}
foreach ($sports as $sport_id) {
foreach ([2, 3] as $alarm_level_id) {
foreach ($alarm_levels as $alarm_level) {
PersonalNotification::firstOrCreate(
['sport_id' => $sport_id, 'user_id' => $user->id, 'bookmaker_id' => $user->bookmaker_id, 'alarm_level_id' => $alarm_level_id],
['sport_id' => $sport_id, 'user_id' => $user->id, 'bookmaker_id' => $user->bookmaker_id, 'alarm_level_id' => $alarm_level->id],
['notify_by_system' => 0, 'notify_by_email' => 0]
);
if ($user->partner_bookmaker_id) {
PersonalNotification::firstOrCreate(
['sport_id' => $sport_id, 'user_id' => $user->id, 'bookmaker_id' => $user->partner_bookmaker_id, 'alarm_level_id' => $alarm_level_id],
['sport_id' => $sport_id, 'user_id' => $user->id, 'bookmaker_id' => $user->partner_bookmaker_id, 'alarm_level_id' => $alarm_level->id],
['notify_by_system' => 0, 'notify_by_email' => 0]
);
}
@@ -23,9 +23,9 @@ class BookmakerIcon extends Column
case 'xl':
return 'h-6 w-30';
case 'lg':
return 'h-5 w-20';
return 'h-5 w-24';
default:
return 'h-4 w-16';
return 'h-4 w-18';
}
}
}
+6 -9
View File
@@ -9,6 +9,7 @@ use Filament\Actions\Contracts\HasActions;
use Filament\Forms\Components\Radio;
use Filament\Schemas\Concerns\InteractsWithSchemas;
use Filament\Schemas\Contracts\HasSchemas;
use Filament\Support\Enums\FontWeight;
use Filament\Tables\Columns\IconColumn;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Columns\TextInputColumn;
@@ -56,19 +57,15 @@ class AlarmBookmaker extends Component implements HasActions, HasSchemas, HasTab
// ->icon(function ($record): string {
// return $record->sport->icon;
// })
// ->color(fn ($record): string => match ($record->level_id) {
// ->color(fn ($record): string => match ($record->alarm_level_id) {
// 1 => 'success',
// 2 => 'warning',
// 3 => 'danger',
// }),
// TextColumn::make('sport.name'),
TextColumn::make('name')
->badge()
->color(fn ($record): string => match ($record->level_id) {
1 => 'info',
2 => 'warning',
3 => 'danger',
}),
TextColumn::make('alarm_level.name')
->color(fn ($record) => $record->alarm_level->color)
->weight(FontWeight::Black),
TextInputColumn::make('alarm_threshold')
->tooltip('Between 0.01 - 2.00')
->width('2rem')
@@ -77,7 +74,7 @@ class AlarmBookmaker extends Component implements HasActions, HasSchemas, HasTab
TextColumn::make('multiline_setting.name')->label('Bettype'),
ToggleColumn::make('disabled'),
])
->defaultSort('level_id')
->defaultSort('alarm_level_id')
->deferFilters(false)
->filters([
Filter::make('multiline_setting_id')
+59 -6
View File
@@ -3,15 +3,22 @@
namespace App\Livewire;
use App\Filament\Tables\Columns\BookmakerIcon;
use App\Models\Bookmaker;
use App\Models\PersonalNotification;
use App\Models\Sport;
use Filament\Actions\Action;
use Filament\Actions\Concerns\InteractsWithActions;
use Filament\Actions\Contracts\HasActions;
use Filament\Schemas\Concerns\InteractsWithSchemas;
use Filament\Schemas\Contracts\HasSchemas;
use Filament\Support\Enums\FontWeight;
use Filament\Support\Enums\IconSize;
use Filament\Tables\Columns\IconColumn;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Concerns\InteractsWithTable;
use Filament\Tables\Contracts\HasTable;
use Filament\Tables\Enums\FiltersLayout;
use Filament\Tables\Filters\SelectFilter;
use Filament\Tables\Table;
use Illuminate\Contracts\View\View;
use Livewire\Component;
@@ -26,13 +33,59 @@ class PersonalNotificationTable extends Component implements HasActions, HasSche
{
return $table
->query(PersonalNotification::query()->with('bookmaker')->where('user_id', auth()->user()->id))
->description('Send a notification when favorit enters an alarm level.')
->striped()
->columns([
IconColumn::make('sport.icon')
->label('')
->icon(fn ($record) => $record->sport->icon)
->tooltip(fn ($record) => $record->id),
TextColumn::make('sport.name'),
BookmakerIcon::make('bookmaker.icon')->label('Icon')->size('lg'),
// TextColumn::make('sport.name'),
BookmakerIcon::make('bookmaker.icon')
->label('Bookmaker')->size('lg'),
// IconColumn::make('sport.icon')
// ->label('')
// ->color(fn ($record) => $record->sport->color)
// ->icon(fn ($record) => $record->sport->icon)
// ->size(IconSize::ExtraLarge),
TextColumn::make('alarm_level.name')
->color(fn ($record) => $record->alarm_level->color)
->weight(FontWeight::Black)
->extraCellAttributes(['class' => 'alarm-level-style']),
])
->defaultSort('alarm_level_id', 'desc')
->deferFilters(false)
->deferFilters(false)
->filters([
SelectFilter::make('bookmaker_id')
->label('Bookmaker')
->visible(fn () => auth()->user()->partner_bookmaker_id)
->default(auth()->user()->bookmaker->id)
->selectablePlaceholder(false)
->options(Bookmaker::options([auth()->user()->partner_bookmaker_id, auth()->user()->bookmaker_id]))
->preload(),
SelectFilter::make('sport_id')
->label('Sport')
->default(1)
->selectablePlaceholder(false)
->options(Sport::getSportForClient(auth()->user()->client_id))
->preload(),
], FiltersLayout::AboveContent)
->filtersFormColumns(3)
->hiddenFilterIndicators()
->recordActions([
Action::make('notify_by_system')
->button()
->label('Send Notification')
->color(fn ($record) => $record->notify_by_system ? 'primary' : 'gray')
->icon('phosphor-bell-duotone')
->action(function ($record) {
PersonalNotification::where('id', $record->id)->update(['notify_by_system' => ! $record->notify_by_system]);
}),
Action::make('notify_by_email')
->label('Send E-Mail')
->button()
->color(fn ($record) => $record->notify_by_email ? 'primary' : 'gray')
->icon('phosphor-envelope-duotone')
->action(function ($record) {
PersonalNotification::where('id', $record->id)->update(['notify_by_email' => ! $record->notify_by_email]);
}),
]);
}
+6 -2
View File
@@ -11,8 +11,7 @@ class AlarmSetting extends Model
'sport_id',
'disabled',
'multiline_setting_id',
'name',
'level_id',
'alarm_level_id',
'alarm_threshold',
];
@@ -25,4 +24,9 @@ class AlarmSetting extends Model
{
return $this->belongsTo(Sport::class);
}
public function alarm_level()
{
return $this->belongsTo(AlarmLevel::class);
}
}
+5
View File
@@ -23,6 +23,11 @@ class Bookmaker extends Model
return $this->belongsTo(Sport::class)->where('is_active', 1);
}
public static function options($arr = [])
{
return Bookmaker::query()->whereIn('id', $arr)->pluck('name', 'id');
}
public static function map()
{
$arr = [];
+5
View File
@@ -24,4 +24,9 @@ class PersonalNotification extends Model
{
return $this->belongsTo(Bookmaker::class);
}
public function alarm_level()
{
return $this->belongsTo(AlarmLevel::class);
}
}
+2 -2
View File
@@ -33,9 +33,9 @@ class Sport extends Model
return Sport::query()->where('is_active', 1)->pluck('id')->toArray();
}
public static function getSportForClient()
public static function getSportForClient($client_id)
{
$sports = Client::where('id', auth()->user()->client_id)->value('sport');
$sports = Client::where('id', $client_id)->value('sport');
return Sport::query()->whereIn('id', $sports)->pluck('name', 'id');
+6
View File
@@ -54,6 +54,12 @@ class AppServiceProvider extends ServiceProvider
Carbon::setLocale(app()->getLocale());
FilamentColor::register([
'primary' => Color::Gray,
'danger' => Color::Red,
'gray' => Color::Zinc,
'info' => Color::Blue,
'success' => Color::Green,
'warning' => Color::Orange,
'home' => Color::Sky,
'away' => Color::Lime,
]);
@@ -17,7 +17,6 @@ use Filament\Http\Middleware\DispatchServingFilamentEvent;
use Filament\Pages\Dashboard;
use Filament\Panel;
use Filament\PanelProvider;
use Filament\Support\Colors\Color;
use Filament\Support\Enums\Width;
use Filament\Widgets\AccountWidget;
use Filament\Widgets\FilamentInfoWidget;
@@ -49,9 +48,6 @@ class AdminPanelProvider extends PanelProvider
// ->databaseNotificationsPolling('15s') default is 30
->profile(isSimple: false)
->default()
->colors([
'primary' => Color::Gray,
])
->globalSearch(false)
->globalSearchKeyBindings(['command+k', 'ctrl+k'])
->brandLogo(asset('images/nuh-odds.svg'))