add alarm level from db
This commit is contained in:
1 parent
4e77862aa7
commit
40f40db63c
28 files changed
+247
-250
No files matched your search
@@ -1,36 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Actions;
|
|
||||||
|
|
||||||
use App\Models\MultilineSetting;
|
|
||||||
use Filament\Notifications\Notification;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
|
|
||||||
class BettypUserGenerator
|
|
||||||
{
|
|
||||||
public static function run($record)
|
|
||||||
{
|
|
||||||
$user_id = (int) $record->id;
|
|
||||||
|
|
||||||
$multilines = MultilineSetting::orderBy('sport_id')->pluck('sport_id', 'id');
|
|
||||||
|
|
||||||
foreach ($multilines as $multiline_setting_id => $sport_id) {
|
|
||||||
|
|
||||||
$is_active = in_array($multiline_setting_id, [1, 2, 9, 10, 16, 17, 22, 23]) ? 1 : 0;
|
|
||||||
|
|
||||||
$setting = [];
|
|
||||||
$setting['sport_id'] = $sport_id;
|
|
||||||
$setting['user_id'] = $user_id;
|
|
||||||
$setting['multiline_setting_id'] = $multiline_setting_id;
|
|
||||||
|
|
||||||
DB::table('bettype_users')->updateOrInsert($setting, ['is_active' => $is_active]);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Notification::make()
|
|
||||||
->title('Bettypes for user generated successfully')
|
|
||||||
->success()
|
|
||||||
->send();
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Actions;
|
|
||||||
|
|
||||||
use App\Models\CompetitionGroup;
|
|
||||||
use App\Models\Country;
|
|
||||||
|
|
||||||
class LoadCountryGroups
|
|
||||||
{
|
|
||||||
public static function load()
|
|
||||||
{
|
|
||||||
$res = Country::query()->select('name', 'id')->get();
|
|
||||||
$countries = [];
|
|
||||||
foreach ($res as $value) {
|
|
||||||
$countries[$value->id] = $value->name;
|
|
||||||
}
|
|
||||||
|
|
||||||
$res = CompetitionGroup::where('sport_id', auth()->user()->sport_id)->select('country_id', 'name', 'id')->get();
|
|
||||||
|
|
||||||
$arr = [];
|
|
||||||
foreach ($res as $value) {
|
|
||||||
if (isset($countries[$value->country_id])) {
|
|
||||||
$arr[$value->id] = $countries[$value->country_id].' '.$value->name;
|
|
||||||
} else {
|
|
||||||
$arr[$value->id] = $value->name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
asort($arr);
|
|
||||||
|
|
||||||
return $arr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Actions;
|
|
||||||
|
|
||||||
use App\Models\MultilineClient;
|
|
||||||
use App\Models\MultilineSetting;
|
|
||||||
use Filament\Notifications\Notification;
|
|
||||||
|
|
||||||
class MultilineGenerator
|
|
||||||
{
|
|
||||||
public static function run($record)
|
|
||||||
{
|
|
||||||
$client_id = $record->id;
|
|
||||||
|
|
||||||
MultilineClient::where('client_id', $client_id)->update(['disabled' => 1]);
|
|
||||||
|
|
||||||
$bookmaker = [0, 6, 30, 649, 117];
|
|
||||||
|
|
||||||
foreach ($record->sport as $sport_id) {
|
|
||||||
|
|
||||||
$multilines = MultilineSetting::where('sport_id', $sport_id)->get();
|
|
||||||
|
|
||||||
foreach ($multilines as $multiline) {
|
|
||||||
|
|
||||||
for ($i = 1; $i <= 4; $i++) {
|
|
||||||
|
|
||||||
MultilineClient::updateOrInsert(
|
|
||||||
['client_id' => $client_id, 'sport_id' => $sport_id, 'multiline_setting_id' => $multiline->id, 'position' => $i],
|
|
||||||
['bookmaker_id' => $bookmaker[$i], 'sort' => $i, 'disabled' => 0]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Notification::make()
|
|
||||||
->title('Multiline generated successfully')
|
|
||||||
->success()
|
|
||||||
->send();
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,123 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Actions;
|
||||||
|
|
||||||
|
use App\Models\AlarmLevel;
|
||||||
|
use App\Models\AlarmSetting;
|
||||||
|
use App\Models\Bookmaker;
|
||||||
|
use App\Models\ComparingBookmaker;
|
||||||
|
use App\Models\MultilineClient;
|
||||||
|
use App\Models\MultilineSetting;
|
||||||
|
use App\Models\Sport;
|
||||||
|
use Filament\Notifications\Notification;
|
||||||
|
|
||||||
|
class SettingGeneratorClient
|
||||||
|
{
|
||||||
|
public static function run($record)
|
||||||
|
{
|
||||||
|
/**************************************************
|
||||||
|
* 1) ALARM SETTING (client_bookmaker_id)
|
||||||
|
**************************************************/
|
||||||
|
$alarm_levels = AlarmLevel::get();
|
||||||
|
|
||||||
|
foreach ($record->sport as $sport_id) {
|
||||||
|
|
||||||
|
foreach ($record->bookmaker as $client_bookmaker_id) {
|
||||||
|
|
||||||
|
$multilines = MultilineSetting::where('sport_id', $sport_id)->get()->pluck('id');
|
||||||
|
|
||||||
|
foreach ($multilines as $multiline_id) {
|
||||||
|
|
||||||
|
foreach ($alarm_levels as $alarm_level) {
|
||||||
|
|
||||||
|
AlarmSetting::firstOrCreate(
|
||||||
|
['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]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**************************************************
|
||||||
|
* 2) MULTILINE SLOTS (client_bookmaker_id)
|
||||||
|
**************************************************/
|
||||||
|
|
||||||
|
$bookmaker_slots = [1 => 6, 2 => 30, 3 => 649, 4 => 126];
|
||||||
|
|
||||||
|
foreach ($record->sport as $sport_id) {
|
||||||
|
|
||||||
|
foreach ($record->bookmaker as $client_bookmaker_id) {
|
||||||
|
|
||||||
|
$multilines = MultilineSetting::where('sport_id', $sport_id)->get()->pluck('id');
|
||||||
|
|
||||||
|
foreach ($multilines as $multiline_id) {
|
||||||
|
|
||||||
|
foreach ($bookmaker_slots as $slot => $bookmaker_id) {
|
||||||
|
|
||||||
|
MultilineClient::firstOrCreate(
|
||||||
|
['client_bookmaker_id' => $client_bookmaker_id, 'sport_id' => $sport_id, 'multiline_setting_id' => $multiline_id, 'position' => $slot],
|
||||||
|
['bookmaker_id' => $bookmaker_id, 'sort' => $slot, 'disabled' => 0]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**************************************************
|
||||||
|
* 4) COMPARING BOOKMAKER (client_bookmaker_id)
|
||||||
|
**************************************************/
|
||||||
|
|
||||||
|
$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 ($record as $client) {
|
||||||
|
|
||||||
|
foreach ($record->bookmaker as $client_bookmaker_id) {
|
||||||
|
|
||||||
|
$i = 1;
|
||||||
|
foreach ($bookmakers_soccer as $bookmaker_id) {
|
||||||
|
$margin_threshold = $bookmaker_id == 110 ? 103 : 115;
|
||||||
|
ComparingBookmaker::updateOrCreate(
|
||||||
|
['method_id' => 1, 'sport_id' => 1, 'client_bookmaker_id' => $client_bookmaker_id, 'bookmaker_id' => $bookmaker_id],
|
||||||
|
['is_active' => 1, 'time_lastcheck' => 600, 'margin_threshold' => $margin_threshold, 'sorting' => $i]
|
||||||
|
);
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$sports = Sport::getActiveSports();
|
||||||
|
if (($key = array_search(1, $sports)) !== false) {
|
||||||
|
unset($sports[$key]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$bookmakers_other = Bookmaker::where('in_other', 1)->orderBy('name')->pluck('id')->toArray();
|
||||||
|
|
||||||
|
ComparingBookmaker::where('method_id', 1)->whereIn('sport_id', $sports)->whereNotIn('bookmaker_id', $bookmakers_other)->delete();
|
||||||
|
|
||||||
|
foreach ($record as $client) {
|
||||||
|
|
||||||
|
foreach ($record->bookmaker as $client_bookmaker_id) {
|
||||||
|
|
||||||
|
foreach ($sports as $sport_id) {
|
||||||
|
$i = 1;
|
||||||
|
foreach ($bookmakers_other as $bookmaker_id) {
|
||||||
|
|
||||||
|
ComparingBookmaker::updateOrCreate(
|
||||||
|
['method_id' => 1, 'sport_id' => $sport_id, 'client_bookmaker_id' => $client_bookmaker_id, 'bookmaker_id' => $bookmaker_id],
|
||||||
|
['is_active' => 1, 'time_lastcheck' => 600, 'margin_threshold' => 110, 'sorting' => $i]
|
||||||
|
);
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Notification::make()
|
||||||
|
->title('Settings generated successfully')
|
||||||
|
->success()
|
||||||
|
->send();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Actions;
|
||||||
|
|
||||||
|
use App\Models\AlarmLevel;
|
||||||
|
use App\Models\BettypeUser;
|
||||||
|
use App\Models\Client;
|
||||||
|
use App\Models\MultilineSetting;
|
||||||
|
use App\Models\PersonalNotification;
|
||||||
|
use App\Models\Sport;
|
||||||
|
use App\Models\User;
|
||||||
|
use Filament\Notifications\Notification;
|
||||||
|
|
||||||
|
class SettingGeneratorUser
|
||||||
|
{
|
||||||
|
public static function run($record)
|
||||||
|
{
|
||||||
|
/**************************************************
|
||||||
|
* 3) BETTYPES for USER in MONITOR
|
||||||
|
**************************************************/
|
||||||
|
|
||||||
|
$multilines = MultilineSetting::orderBy('sport_id')->pluck('sport_id', 'id');
|
||||||
|
|
||||||
|
foreach ($multilines as $multiline_setting_id => $sport_id) {
|
||||||
|
|
||||||
|
$is_active = in_array($multiline_setting_id, [1, 2, 9, 10, 16, 17, 22, 23]) ? 1 : 0;
|
||||||
|
|
||||||
|
BettypeUser::firstOrCreate(
|
||||||
|
['sport_id' => $sport_id, 'user_id' => $record->id, 'multiline_setting_id' => $multiline_setting_id],
|
||||||
|
['is_active' => $is_active],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**************************************************
|
||||||
|
* 5) ALARM NOTIFICATION SETTINGS FOR USERS
|
||||||
|
**************************************************/
|
||||||
|
|
||||||
|
if (in_array($record->id, [1, 2])) {
|
||||||
|
$sports = Sport::where('is_active', 1)->pluck('id')->toArray();
|
||||||
|
} else {
|
||||||
|
$sports = Client::find($record->client_id)->value('sport');
|
||||||
|
}
|
||||||
|
$alarm_levels = AlarmLevel::get();
|
||||||
|
|
||||||
|
foreach ($sports as $sport_id) {
|
||||||
|
foreach ($alarm_levels as $alarm_level) {
|
||||||
|
|
||||||
|
PersonalNotification::firstOrCreate(
|
||||||
|
['sport_id' => $sport_id, 'user_id' => $record->id, 'bookmaker_id' => $record->bookmaker_id, 'alarm_level_id' => $alarm_level->id],
|
||||||
|
['notify_by_system' => 0, 'notify_by_email' => 0]
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($record->partner_bookmaker_id) {
|
||||||
|
PersonalNotification::firstOrCreate(
|
||||||
|
['sport_id' => $sport_id, 'user_id' => $record->id, 'bookmaker_id' => $record->partner_bookmaker_id, 'alarm_level_id' => $alarm_level->id],
|
||||||
|
['notify_by_system' => 0, 'notify_by_email' => 0]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Notification::make()
|
||||||
|
->title('Settings for user generated successfully')
|
||||||
|
->success()
|
||||||
|
->send();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -32,11 +32,11 @@ class GenerateSetting
|
|||||||
$sports = Sport::getActiveSports();
|
$sports = Sport::getActiveSports();
|
||||||
|
|
||||||
/**************************************************
|
/**************************************************
|
||||||
* 1) ALARM BOOKMAKER
|
* 1) ALARM SETTING (client_bookmaker_id)
|
||||||
**************************************************/
|
**************************************************/
|
||||||
|
|
||||||
if ($debug) {
|
if ($debug) {
|
||||||
Notice::note('1) ALARM BOOKMAKER', 'p');
|
Notice::note('1) ALARM SETTING', 'p');
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($clients as $client) {
|
foreach ($clients as $client) {
|
||||||
@@ -62,7 +62,7 @@ class GenerateSetting
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**************************************************
|
/**************************************************
|
||||||
* 2) MULTILINE SLOTS
|
* 2) MULTILINE SLOTS (client_bookmaker_id)
|
||||||
**************************************************/
|
**************************************************/
|
||||||
|
|
||||||
if ($debug) {
|
if ($debug) {
|
||||||
@@ -94,7 +94,7 @@ class GenerateSetting
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**************************************************
|
/**************************************************
|
||||||
* 3) BETTYPES for USER in MONITOR
|
* 3) BETTYPES for USER in MONITOR (user_id)
|
||||||
**************************************************/
|
**************************************************/
|
||||||
|
|
||||||
if ($debug) {
|
if ($debug) {
|
||||||
@@ -117,7 +117,7 @@ class GenerateSetting
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**************************************************
|
/**************************************************
|
||||||
* 4) COMPARING BOOKMAKER
|
* 4) COMPARING BOOKMAKER (client_bookmaker_id)
|
||||||
**************************************************/
|
**************************************************/
|
||||||
|
|
||||||
if ($debug) {
|
if ($debug) {
|
||||||
@@ -176,7 +176,7 @@ class GenerateSetting
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**************************************************
|
/**************************************************
|
||||||
* 5) ALARM NOTIFICATION SETTINGS FOR USERS
|
* 5) ALARM NOTIFICATION SETTINGS FOR USERS (user_id)
|
||||||
**************************************************/
|
**************************************************/
|
||||||
|
|
||||||
if ($debug) {
|
if ($debug) {
|
||||||
|
|||||||
@@ -2,8 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Filament\Resources\Clients\Tables;
|
namespace App\Filament\Resources\Clients\Tables;
|
||||||
|
|
||||||
use App\Actions\AlarmGenerator;
|
use App\Actions\SettingGeneratorClient;
|
||||||
use App\Actions\MultilineGenerator;
|
|
||||||
use App\Models\Bookmaker;
|
use App\Models\Bookmaker;
|
||||||
use App\Models\Provider;
|
use App\Models\Provider;
|
||||||
use App\Models\Sport;
|
use App\Models\Sport;
|
||||||
@@ -37,17 +36,11 @@ class ClientsTable
|
|||||||
->formatStateUsing(fn (string $state): string => Sport::where('id', $state)->pluck('name')->first()),
|
->formatStateUsing(fn (string $state): string => Sport::where('id', $state)->pluck('name')->first()),
|
||||||
])
|
])
|
||||||
->recordActions([
|
->recordActions([
|
||||||
Action::make('multiline')
|
Action::make('Create Settings')
|
||||||
->icon('phosphor-gear-fine')
|
->icon('phosphor-gear-fine')
|
||||||
->tooltip('Generates basic alarm configuration for client')
|
->tooltip('Generates basic configuration for client')
|
||||||
->action(function ($record) {
|
->action(function ($record) {
|
||||||
MultilineGenerator::run($record);
|
SettingGeneratorClient::run($record);
|
||||||
}),
|
|
||||||
Action::make('alarm')
|
|
||||||
->icon('phosphor-gear-fine')
|
|
||||||
->tooltip('Generates basic multiline configuration for client')
|
|
||||||
->action(function ($record) {
|
|
||||||
AlarmGenerator::run($record);
|
|
||||||
}),
|
}),
|
||||||
EditAction::make()->hiddenLabel(),
|
EditAction::make()->hiddenLabel(),
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -10,8 +10,10 @@ class LoadBettype
|
|||||||
public static function load()
|
public static function load()
|
||||||
{
|
{
|
||||||
$res = BettypeUser::with('multiline_setting')
|
$res = BettypeUser::with('multiline_setting')
|
||||||
->orderBy('multiline_setting_id')
|
->where('user_id', auth()->user()->id)
|
||||||
|
->where('sport_id', auth()->user()->sport_id)
|
||||||
->where('is_active', 1)
|
->where('is_active', 1)
|
||||||
|
->orderBy('multiline_setting_id')
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
$arr = [];
|
$arr = [];
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ class LoadMultiline
|
|||||||
}
|
}
|
||||||
|
|
||||||
$res = MultilineClient::with('multiline_setting')
|
$res = MultilineClient::with('multiline_setting')
|
||||||
|
->where('sport_id', auth()->user()->sport_id)
|
||||||
->where('client_bookmaker_id', auth()->user()->bookmaker_id)
|
->where('client_bookmaker_id', auth()->user()->bookmaker_id)
|
||||||
->select('bookmaker_id', 'multiline_setting_id')
|
->select('bookmaker_id', 'multiline_setting_id')
|
||||||
->orderBy('sort')
|
->orderBy('sort')
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Filament\Resources\Users\Tables;
|
namespace App\Filament\Resources\Users\Tables;
|
||||||
|
|
||||||
use App\Actions\BettypUserGenerator;
|
use App\Actions\SettingGeneratorUser;
|
||||||
use Filament\Actions\Action;
|
use Filament\Actions\Action;
|
||||||
use Filament\Actions\EditAction;
|
use Filament\Actions\EditAction;
|
||||||
use Filament\Tables\Columns\TextColumn;
|
use Filament\Tables\Columns\TextColumn;
|
||||||
@@ -36,11 +36,11 @@ class UsersTable
|
|||||||
//
|
//
|
||||||
])
|
])
|
||||||
->recordActions([
|
->recordActions([
|
||||||
Action::make('bettype')
|
Action::make('Create Settings')
|
||||||
->icon('phosphor-gear-fine')
|
->icon('phosphor-gear-fine')
|
||||||
->tooltip('Generates basic bettype monitor configuration for this user')
|
->tooltip('Generates basic configuration for this user')
|
||||||
->action(function ($record) {
|
->action(function ($record) {
|
||||||
BettypUserGenerator::run($record);
|
SettingGeneratorUser::run($record);
|
||||||
}),
|
}),
|
||||||
EditAction::make()->hiddenLabel(),
|
EditAction::make()->hiddenLabel(),
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ class BettypeToggle extends Component
|
|||||||
$this->bettype_toggles = [];
|
$this->bettype_toggles = [];
|
||||||
|
|
||||||
$res = BettypeUser::with('multiline_setting')
|
$res = BettypeUser::with('multiline_setting')
|
||||||
|
->where('user_id', auth()->user()->id)
|
||||||
|
->where('sport_id', auth()->user()->sport_id)
|
||||||
->orderBy('multiline_setting_id')
|
->orderBy('multiline_setting_id')
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
|
|||||||
@@ -38,10 +38,11 @@ class ClientGroupListEditor extends Component implements HasActions, HasSchemas,
|
|||||||
->badge()
|
->badge()
|
||||||
->wrap()
|
->wrap()
|
||||||
->color('info')
|
->color('info')
|
||||||
->formatStateUsing(fn (string $state): string => CompetitionGroup::where('id', $state)->pluck('name')->first()),
|
->formatStateUsing(function (string $state): string {
|
||||||
])
|
$res = CompetitionGroup::with('country')->where('id', $state)->first();
|
||||||
->filters([
|
|
||||||
// ...
|
return $res->country->name.' '.$res->name;
|
||||||
|
}),
|
||||||
])
|
])
|
||||||
->recordActions([
|
->recordActions([
|
||||||
EditAction::make('edit')
|
EditAction::make('edit')
|
||||||
@@ -57,13 +58,22 @@ class ClientGroupListEditor extends Component implements HasActions, HasSchemas,
|
|||||||
->required()
|
->required()
|
||||||
->maxLength(255),
|
->maxLength(255),
|
||||||
Select::make('client_groups')
|
Select::make('client_groups')
|
||||||
->searchable()
|
|
||||||
->multiple()
|
->multiple()
|
||||||
|
->required()
|
||||||
->preload()
|
->preload()
|
||||||
->options(fn () => LoadCountryGroups::load()),
|
->searchable()
|
||||||
])->action(function ($livewire) {
|
->options(function (): array {
|
||||||
$livewire->dispatch('refreshBettypeMenu');
|
$res = CompetitionGroup::with('country')->get();
|
||||||
|
$arr = [];
|
||||||
|
foreach ($res as $value) {
|
||||||
|
$arr[$value->id] = $value->country?->name.' '.$value->name;
|
||||||
|
}
|
||||||
|
asort($arr, SORT_STRING);
|
||||||
|
|
||||||
|
return $arr;
|
||||||
|
|
||||||
}),
|
}),
|
||||||
|
]),
|
||||||
DeleteAction::make('delete')->iconButton(),
|
DeleteAction::make('delete')->iconButton(),
|
||||||
])
|
])
|
||||||
->headerActions([
|
->headerActions([
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ class UserNotifications extends Component implements HasActions, HasSchemas, Has
|
|||||||
{
|
{
|
||||||
return $table
|
return $table
|
||||||
->query(User::query()->where('client_id', auth()->user()->client_id)->orwhereIn('id', [1, 2]))
|
->query(User::query()->where('client_id', auth()->user()->client_id)->orwhereIn('id', [1, 2]))
|
||||||
->description('Send a message to one of the users listed')
|
->description('Send a message to one of the user listed')
|
||||||
->columns([
|
->columns([
|
||||||
TextColumn::make('name')->icon('phosphor-user-duotone')->searchable(),
|
TextColumn::make('name')->icon('phosphor-user-duotone')->searchable(),
|
||||||
TextColumn::make('email')->icon('phosphor-envelope-duotone'),
|
TextColumn::make('email')->icon('phosphor-envelope-duotone'),
|
||||||
|
|||||||
@@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use App\Models\Scopes\SportScope;
|
|
||||||
use App\Models\Scopes\UserScope;
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
class BettypeUser extends Model
|
class BettypeUser extends Model
|
||||||
@@ -16,12 +14,6 @@ class BettypeUser extends Model
|
|||||||
'unique_key',
|
'unique_key',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected static function booted(): void
|
|
||||||
{
|
|
||||||
static::addGlobalScope(new SportScope);
|
|
||||||
static::addGlobalScope(new UserScope);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function multiline_setting()
|
public function multiline_setting()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(MultilineSetting::class);
|
return $this->belongsTo(MultilineSetting::class);
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||||||
class ClientGroupList extends Model
|
class ClientGroupList extends Model
|
||||||
{
|
{
|
||||||
protected $casts = [
|
protected $casts = [
|
||||||
'client_groups' => 'json',
|
'client_groups' => 'array',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
|
|||||||
@@ -23,4 +23,9 @@ class CompetitionGroup extends Model
|
|||||||
{
|
{
|
||||||
return $this->belongsTo(Sport::class);
|
return $this->belongsTo(Sport::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function country()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Country::class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use App\Models\Scopes\SportScope;
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
class Event extends Model
|
class Event extends Model
|
||||||
@@ -28,11 +27,6 @@ class Event extends Model
|
|||||||
'away_id',
|
'away_id',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected static function booted(): void
|
|
||||||
{
|
|
||||||
static::addGlobalScope(new SportScope);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function provider()
|
public function provider()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Provider::class);
|
return $this->belongsTo(Provider::class);
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use App\Models\Scopes\ClientScope;
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
class EventUserNote extends Model
|
class EventUserNote extends Model
|
||||||
@@ -16,11 +15,6 @@ class EventUserNote extends Model
|
|||||||
'deleted',
|
'deleted',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected static function booted(): void
|
|
||||||
{
|
|
||||||
static::addGlobalScope(new ClientScope);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function user()
|
public function user()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(User::class);
|
return $this->belongsTo(User::class);
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use App\Models\Scopes\UserScope;
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
class EventUserStar extends Model
|
class EventUserStar extends Model
|
||||||
@@ -11,9 +10,4 @@ class EventUserStar extends Model
|
|||||||
'event_id',
|
'event_id',
|
||||||
'user_id',
|
'user_id',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected static function booted(): void
|
|
||||||
{
|
|
||||||
static::addGlobalScope(new UserScope);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use App\Models\Scopes\SportScope;
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
class MultilineClient extends Model
|
class MultilineClient extends Model
|
||||||
@@ -31,9 +30,4 @@ class MultilineClient extends Model
|
|||||||
{
|
{
|
||||||
return $this->belongsTo(Bookmaker::class);
|
return $this->belongsTo(Bookmaker::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static function booted(): void
|
|
||||||
{
|
|
||||||
static::addGlobalScope(new SportScope);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -13,9 +13,4 @@ class MultilineSetting extends Model
|
|||||||
'short',
|
'short',
|
||||||
'table',
|
'table',
|
||||||
];
|
];
|
||||||
|
|
||||||
public function sport()
|
|
||||||
{
|
|
||||||
return $this->belongsTo(Sport::class);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Models\Scopes;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
|
||||||
use Illuminate\Database\Eloquent\Scope;
|
|
||||||
|
|
||||||
class ClientScope implements Scope
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Apply the scope to a given Eloquent query builder.
|
|
||||||
*/
|
|
||||||
public function apply(Builder $builder, Model $model): void
|
|
||||||
{
|
|
||||||
if (auth()->hasUser()) {
|
|
||||||
$builder->where('client_id', auth()->user()->client_id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Models\Scopes;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
|
||||||
use Illuminate\Database\Eloquent\Scope;
|
|
||||||
|
|
||||||
class SportScope implements Scope
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Apply the scope to a given Eloquent query builder.
|
|
||||||
*/
|
|
||||||
public function apply(Builder $builder, Model $model): void
|
|
||||||
{
|
|
||||||
if (auth()->hasUser()) {
|
|
||||||
$builder->where('sport_id', auth()->user()->sport_id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Models\Scopes;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
|
||||||
use Illuminate\Database\Eloquent\Scope;
|
|
||||||
|
|
||||||
class UserScope implements Scope
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Apply the scope to a given Eloquent query builder.
|
|
||||||
*/
|
|
||||||
public function apply(Builder $builder, Model $model): void
|
|
||||||
{
|
|
||||||
if (auth()->hasUser()) {
|
|
||||||
$builder->where('user_id', auth()->user()->id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Generated
+3
-3
@@ -12983,12 +12983,12 @@
|
|||||||
],
|
],
|
||||||
"aliases": [],
|
"aliases": [],
|
||||||
"minimum-stability": "stable",
|
"minimum-stability": "stable",
|
||||||
"stability-flags": {},
|
"stability-flags": [],
|
||||||
"prefer-stable": true,
|
"prefer-stable": true,
|
||||||
"prefer-lowest": false,
|
"prefer-lowest": false,
|
||||||
"platform": {
|
"platform": {
|
||||||
"php": "^8.3"
|
"php": "^8.3"
|
||||||
},
|
},
|
||||||
"platform-dev": {},
|
"platform-dev": [],
|
||||||
"plugin-api-version": "2.9.0"
|
"plugin-api-version": "2.6.0"
|
||||||
}
|
}
|
||||||
@@ -14,8 +14,8 @@ class AlarmLevelSeeder extends Seeder
|
|||||||
*/
|
*/
|
||||||
$sql = "INSERT INTO `alarm_levels` (`id`, `name`, `color`, `default_threshold`, `created_at`, `updated_at`)
|
$sql = "INSERT INTO `alarm_levels` (`id`, `name`, `color`, `default_threshold`, `created_at`, `updated_at`)
|
||||||
VALUES
|
VALUES
|
||||||
(1, 'LEVEL 1', 'info', 0.01, NULL, NULL),
|
(1, 'LEVEL 1', 'success', 0.01, NULL, NULL),
|
||||||
(2, 'LEVEL 2', 'warning', 0.20, NULL, NULL),
|
(2, 'LEVEL 2', 'info', 0.20, NULL, NULL),
|
||||||
(3, 'LEVEL 3', 'danger', 0.30, NULL, NULL);
|
(3, 'LEVEL 3', 'danger', 0.30, NULL, NULL);
|
||||||
";
|
";
|
||||||
DB::unprepared($sql);
|
DB::unprepared($sql);
|
||||||
|
|||||||
@@ -89,11 +89,11 @@ button[wire\:click="resetTableFiltersForm"] {
|
|||||||
/* Styling Radio Lable */
|
/* Styling Radio Lable */
|
||||||
|
|
||||||
.fi-fo-radio {
|
.fi-fo-radio {
|
||||||
@apply !grid grid-cols-2 gap-y-4 my-2
|
@apply !grid grid-cols-3 gap-y-2 mb-2
|
||||||
}
|
}
|
||||||
|
|
||||||
.fi-fo-radio-label {
|
.fi-fo-radio-label {
|
||||||
@apply p-3 border border-gray-200 shadow rounded-md cursor-pointer has-checked:bg-blue-50 has-checked:text-blue-900 dark:has-checked:bg-blue-950 dark:has-checked:text-blue-200
|
@apply p-2 border border-gray-200 shadow rounded-md cursor-pointer has-checked:bg-blue-50 has-checked:text-blue-900 dark:has-checked:bg-blue-950 dark:has-checked:text-blue-200
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -62,7 +62,7 @@
|
|||||||
|
|
||||||
{{-- Notifications --}}
|
{{-- Notifications --}}
|
||||||
|
|
||||||
<x-filament::modal slide-over width="2xl" icon="phosphor-warning-duotone" :close-by-clicking-away="true" :close-by-escaping="true"
|
<x-filament::modal width="2xl" icon="phosphor-warning-duotone" :close-by-clicking-away="true" :close-by-escaping="true"
|
||||||
:close-button="true">
|
:close-button="true">
|
||||||
<x-slot name="trigger">
|
<x-slot name="trigger">
|
||||||
<x-filament::button outlined icon="phosphor-warning-duotone" class="my-auto" color="gray"
|
<x-filament::button outlined icon="phosphor-warning-duotone" class="my-auto" color="gray"
|
||||||
@@ -199,7 +199,7 @@
|
|||||||
</x-filament::modal>
|
</x-filament::modal>
|
||||||
|
|
||||||
{{-- Multiline --}}
|
{{-- Multiline --}}
|
||||||
<x-filament::modal slide-over width="4xl" icon="phosphor-equals" :close-by-clicking-away="true" :close-by-escaping="true" :close-button="true">
|
<x-filament::modal width="4xl" icon="phosphor-equals" :close-by-clicking-away="true" :close-by-escaping="true" :close-button="true">
|
||||||
<x-slot name="trigger">
|
<x-slot name="trigger">
|
||||||
<x-filament::button outlined icon="phosphor-equals" color="gray" class="my-auto"
|
<x-filament::button outlined icon="phosphor-equals" color="gray" class="my-auto"
|
||||||
tooltip="Multiline Settings">
|
tooltip="Multiline Settings">
|
||||||
@@ -213,7 +213,7 @@
|
|||||||
|
|
||||||
{{-- Alarm --}}
|
{{-- Alarm --}}
|
||||||
|
|
||||||
<x-filament::modal slide-over width="4xl" icon="phosphor-siren-duotone" :close-by-clicking-away="true" :close-by-escaping="true"
|
<x-filament::modal width="4xl" icon="phosphor-siren-duotone" :close-by-clicking-away="true" :close-by-escaping="true"
|
||||||
:close-button="true">
|
:close-button="true">
|
||||||
<x-slot name="trigger">
|
<x-slot name="trigger">
|
||||||
<x-filament::button outlined icon="phosphor-siren-duotone" color="gray" class="my-auto"
|
<x-filament::button outlined icon="phosphor-siren-duotone" color="gray" class="my-auto"
|
||||||
@@ -246,7 +246,7 @@
|
|||||||
</x-filament::modal>
|
</x-filament::modal>
|
||||||
|
|
||||||
{{-- Custom Groups --}}
|
{{-- Custom Groups --}}
|
||||||
<x-filament::modal slide-over width="3xl" icon="phosphor-user-list" :close-by-clicking-away="true" :close-by-escaping="true" :close-button="true">
|
<x-filament::modal width="4xl" icon="phosphor-user-list" :close-by-clicking-away="true" :close-by-escaping="true" :close-button="true">
|
||||||
<x-slot name="trigger">
|
<x-slot name="trigger">
|
||||||
<x-filament::button outlined icon="phosphor-user-list" color="gray" class="my-auto"
|
<x-filament::button outlined icon="phosphor-user-list" color="gray" class="my-auto"
|
||||||
tooltip="Custom Groups">
|
tooltip="Custom Groups">
|
||||||
|
|||||||
Reference in new issue
Block a user