This commit is contained in:
salam committed 2026-02-05 18:48:51 +01:00
1 parent b0a002c7c1
commit 23cf804865
23 files changed
+283 -123

No files matched your search

@@ -7,6 +7,7 @@ use App\Console\Commands\Services\Tasks\DBMapper;
use App\Console\Commands\Services\Tasks\GenerateAlarms;
use App\Console\Commands\Services\Tasks\GenerateSetting;
use App\Console\Commands\Services\Tasks\MarketsList;
use App\Console\Commands\Services\Tasks\NotifyAlarms;
use App\Console\Commands\Services\Tasks\TxoddsFlags;
class Services
@@ -29,6 +30,9 @@ class Services
case 'Generate Alarms':
GenerateAlarms::run();
break;
case 'Notify Alarms':
NotifyAlarms::run();
break;
}
}
@@ -10,6 +10,7 @@ use App\Models\Client;
use App\Models\ComparingBookmaker;
use App\Models\MultilineClient;
use App\Models\MultilineSetting;
use App\Models\PersonalNotification;
use App\Models\Sport;
use App\Models\User;
use App\Utilities\Notice;
@@ -178,5 +179,37 @@ class GenerateSetting
}
}
/**************************************************
* 5) ALARM NOTIFICATION SETTINGS FOR USERS
**************************************************/
if ($debug) {
Notice::note('5) ALARM NOTIFICATION SETTINGS FOR USERS', 'p');
}
$users = User::with('client')->get();
foreach ($users as $user) {
if (in_array($user->id, [1, 2])) {
$sports = Sport::where('is_active', 1)->pluck('id')->toArray();
} else {
$sports = Client::find($user->client_id)->value('sport');
}
foreach ($sports as $sport_id) {
foreach ([2, 3] as $alarm_level_id) {
PersonalNotification::firstOrCreate(
['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],
['notify_by_system' => 0, 'notify_by_email' => 0]
);
}
}
}
}
}
}
@@ -0,0 +1,28 @@
<?php
namespace App\Console\Commands\Services\Tasks;
use App\Console\Commands\Nuh;
use App\Models\User;
use App\Utilities\Notice;
class NotifyAlarms
{
public static function run()
{
$debug = Nuh::$options['d'] ?? 0;
if ($debug) {
Notice::note('Notify Alarms', 'b');
}
/**
* USER
*/
$users = User::all();
foreach ($users as $user) {
dd($user);
}
}
}