work on moving customers from tahesab 3
This commit is contained in:
@@ -195,9 +195,9 @@ class TahesabController extends Controller
|
||||
$errors = [];
|
||||
|
||||
foreach ($validated['customers'] as $item) {
|
||||
// تلفن خالی نباید به موبایل «0» تبدیل شود (وگرنه روی unique برخورد میکند)
|
||||
// ستون mobile در دیتابیس NOT NULL است؛ پس برای تلفن خالی رشتهٔ خالی میگذاریم نه null
|
||||
$tel = trim((string) ($item['tel'] ?? ''));
|
||||
$mobile = $tel !== '' ? '0' . ltrim($tel, '0') : null;
|
||||
$mobile = $tel !== '' ? '0' . ltrim($tel, '0') : '';
|
||||
|
||||
// اگر مشتری با همین کد قبلاً ثبت شده، عملیات موفق در نظر گرفته میشود (idempotent)
|
||||
if (Customer::whereNull('deleted_at')->where('moshtari_code', $item['code'])->exists()) {
|
||||
@@ -218,7 +218,7 @@ class TahesabController extends Controller
|
||||
$customer = Customer::create([
|
||||
'name' => trim($item['name']),
|
||||
'fname' => trim($item['name']),
|
||||
'mobile' => $mobile ?: null,
|
||||
'mobile' => $mobile,
|
||||
'active' => true,
|
||||
'moshtari_code' => $item['code'],
|
||||
'referral_id' => $referralId,
|
||||
|
||||
Reference in New Issue
Block a user