سلام دوستان
validate زیر را فرض کنین دارم
$data = $request->validate([
'name' => ['required', 'persian_alpha', 'string', 'max:100'],
'family' => ['required', 'persian_alpha', 'string', 'max:100'],
'office_id' => ['required', 'string'],
'manual_code' => ['nullable'],
'accounting_id' => ['required_if:manual_code,on', 'nullable', 'string', 'max:30'],
'company_name' => ['nullable', 'string', 'max:100'],
'national_id' => ['nullable', 'string', 'max:100'],
'economic_code' => ['nullable', 'string', 'max:100'],
'registration_number' => ['nullable', 'string', 'max:100'],
'avatar' => 'nullable|image|mimes:jpg,png|dimensions:max_width=800,max_height=800',
'phone' => ['nullable', 'string', 'max:100'],
'mobile' => ['nullable', 'string', 'max:100'],
'email' => ['nullable', 'email:dns', 'string', 'max:100'],
'instagram' => ['nullable', 'string', 'max:100'],
'telegram' => ['nullable', 'string', 'max:100'],
'website' => ['nullable', 'string', 'max:100'],
'state' => ['nullable', 'string', 'max:100'],
'city' => ['nullable', 'string', 'max:100'],
'postal_code' => ['nullable', 'string', 'max:100'],
'address' => ['nullable', 'string'],
'information' => ['nullable', 'string'],
]);
چطور میتونم بررسی کنم که اگر فیلد name و family همزمان در دیتابیس بودند خطا برگردونه برای unique بودنشون ؟
مثلا علی عباسی هست قبلا تو دیتابیس و دوباره اشتباها میزنیم علی عباسی ، خب الان میخوام که پیغام یونیک بودن بده
ولی اگر زدیم علی رمضانی پیغام نده
یا اگر زدیم محمد عباسی پیغام نده
سلام دوست عزیز
باید به دیتابیس متصل شید یک کوئری شامل نام و فامیلی بفرستید اگر پاسخ گرفتید ارور یونیک و اگر پاسخ نگرفتید کاربر رو ثبت کنید
شاید پاسخ شما همینجا باشد