diff --git a/app/Http/Controllers/ServiceController.php b/app/Http/Controllers/ServiceController.php
index fb0e2e3..48448ee 100644
--- a/app/Http/Controllers/ServiceController.php
+++ b/app/Http/Controllers/ServiceController.php
@@ -3,6 +3,7 @@
namespace App\Http\Controllers;
use Illuminate\Http\Request;
+use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Auth;
use Illuminate\View\View;
@@ -22,7 +23,15 @@ class ServiceController extends Controller
session()->flash('service_update',TRUE);
$validation = $request->validate([
- 'service.domain_name' => sprintf('required|unique:%s,domain_name,%d',$o->type->getTable(),$o->type->id),
+ 'service.domain_name' => ['required',function($attribute,$value,$fail) use ($request,$o) {
+ if (Service\Domain::where('domain_name',$value)
+ ->where('domain_tld_id',Arr::get($request,'service.domain_tld_id'))
+ ->when($o->type,function($q) use ($o) { return $q->where('id','<>',$o->type->id); })
+ ->count() > 0)
+ {
+ $fail('Domain already exists.');
+ }
+ }],
'service.domain_expire' => 'required|date',
'service.domain_tld_id' => 'required|exists:ab_domain_tld,id',
'service.domain_registrar_id' => 'required|exists:ab_domain_registrar,id',
diff --git a/resources/views/theme/backend/adminlte/a/service/widgets/domain/update.blade.php b/resources/views/theme/backend/adminlte/a/service/widgets/domain/update.blade.php
index f8e1e7d..f24c99d 100644
--- a/resources/views/theme/backend/adminlte/a/service/widgets/domain/update.blade.php
+++ b/resources/views/theme/backend/adminlte/a/service/widgets/domain/update.blade.php
@@ -12,7 +12,7 @@
@@ -60,7 +60,7 @@
@@ -107,7 +107,7 @@