added table of co-woeker requests and new features

This commit is contained in:
2026-08-16 20:03:18 +03:30
parent 6fffd84584
commit acd1c2ea20
5 changed files with 110 additions and 8 deletions
@@ -18,11 +18,26 @@ class MassageController extends Controller
{
public function send_message(Request $request)
{
if($this->Config('group_sms') == 'false'){
if (! app(ConfigService::class)->getBool('group_sms', false)) {
throw new UnprocessableEntityHttpException('پیامک گروهی غیرفعال است.');
}
$numbers = array_values(array_unique(array_filter(
array_map('strval', (array) ($request->numbers ?? [])),
static fn ($n) => trim($n) !== ''
)));
if ($numbers === []) {
throw new UnprocessableEntityHttpException('حداقل یک شماره لازم است.');
}
// هر درخواست حداکثر ۱۰ شماره — ادمین باید دسته‌ای بفرستد تا پنل پیامک زیر فشار نرود
if (count($numbers) > 10) {
throw new UnprocessableEntityHttpException('در هر درخواست حداکثر ۱۰ شماره مجاز است.');
}
// یافتن مشتریان با شماره‌های داده شده
$customers = Customer::whereIn('mobile', $request->numbers)->get();
$customers = Customer::whereIn('mobile', $numbers)->get();
$filter = app(SmsProfanityFilter::class);
$filter->assertClean((string) ($request->message ?? ''));
@@ -35,6 +50,15 @@ class MassageController extends Controller
$this->send($customer->mobile, $message);
}
// شماره‌های دستی که مشتری در DB ندارند
$known = $customers->pluck('mobile')->all();
foreach ($numbers as $mobile) {
if (in_array($mobile, $known, true)) {
continue;
}
$this->send($mobile, (string) $request->message);
}
return response()->json(true);
}