diff --git a/app/Http/Controllers/ServiceController.php b/app/Http/Controllers/ServiceController.php index a38152d..cef2169 100644 --- a/app/Http/Controllers/ServiceController.php +++ b/app/Http/Controllers/ServiceController.php @@ -228,41 +228,6 @@ class ServiceController extends Controller } } - /** - * Edit a domain service details - * - * @param Request $request - * @param Service $o - * @return RedirectResponse - * @deprecated - use update() - */ - public function domain_edit(Request $request,Service $o) - { - session()->flash('service_update',TRUE); - - $validation = $request->validate([ - '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', - 'service.registrar_account' => 'required', - 'service.registrar_username' => 'required|string|min:5', - 'service.registrar_ns' => 'required|string|min:5', - ]); - - $o->type->forceFill($validation['service'])->save(); - - return redirect()->back()->with('success','Record updated.'); - } - /** * List all the domains managed by the user * diff --git a/app/Models/DomainRegistrar.php b/app/Models/DomainRegistrar.php index c343408..a72999d 100644 --- a/app/Models/DomainRegistrar.php +++ b/app/Models/DomainRegistrar.php @@ -5,12 +5,7 @@ namespace App\Models; use Illuminate\Database\Eloquent\Model; use Leenooks\Traits\ScopeActive; -/** - * @deprecated - */ class DomainRegistrar extends Model { use ScopeActive; - - protected $table = 'ab_domain_registrar'; } \ No newline at end of file diff --git a/app/Models/DomainTld.php b/app/Models/DomainTld.php deleted file mode 100644 index 373ddcb..0000000 --- a/app/Models/DomainTld.php +++ /dev/null @@ -1,35 +0,0 @@ -hasMany(Service::class); - } - - /* ATTRIBUTES */ - - public function getNameAttribute($value): string - { - return strtoupper($value); - } - - public function getPriceGroupAttribute($value): array - { - return unserialize($value); - } -} \ No newline at end of file diff --git a/app/Models/HostServer.php b/app/Models/HostServer.php deleted file mode 100644 index 6313eda..0000000 --- a/app/Models/HostServer.php +++ /dev/null @@ -1,10 +0,0 @@ - 'nullable|string|min:2', + 'tld_id' => 'required|exists:tlds,id', + 'expire_at' => 'required|date', + 'domain_registrar_id' => 'required|exists:domain_registrars,id', + 'registrar_account' => 'nullable|string', + 'registrar_ns' => 'nullable|string', + 'registrar_username' => 'nullable|string', + ]; + } + /* RELATIONS */ public function registrar() diff --git a/app/Models/Service/Host.php b/app/Models/Service/Host.php index 6af41c0..35bec09 100644 --- a/app/Models/Service/Host.php +++ b/app/Models/Service/Host.php @@ -2,7 +2,7 @@ namespace App\Models\Service; -use App\Models\HostServer; +use App\Models\SupplierHostServer; use App\Traits\ServiceDomains; /** @@ -20,6 +20,25 @@ class Host extends Type public function provider() { - return $this->belongsTo(HostServer::class,'host_server_id'); + return $this->belongsTo(SupplierHostServer::class,'supplier_host_server_id'); + } + + /* OVERRIDES */ + + /** + * Service update validation + * + * @return array + */ + public function validation(): array + { + return [ + 'domain_name' => 'nullable|string|min:2', + 'tld_id' => 'required|exists:tlds,id', + 'expire_at' => 'required|date', + 'supplier_host_server_id' => 'required|exists:supplier_host_servers,id', + 'host_username' => 'nullable|string', + 'host_password' => 'nullable|string', + ]; } } \ No newline at end of file diff --git a/app/Models/SupplierHostServer.php b/app/Models/SupplierHostServer.php new file mode 100644 index 0000000..90b5c4a --- /dev/null +++ b/app/Models/SupplierHostServer.php @@ -0,0 +1,11 @@ +datetime('created_at')->nullable()->after('id'); + $table->datetime('updated_at')->nullable()->after('created_at'); + + $table->dropForeign('ab_domain_registrar_site_id_foreign'); + $table->dropIndex('ab_domain_registrar_id_site_id_index'); + + $table->foreign(['site_id'])->references(['id'])->on('sites'); + }); + + Schema::table('service_domain', function (Blueprint $table) { + $table->foreign(['domain_registrar_id','site_id'])->references(['id','site_id'])->on('domain_registrars'); + }); + + DB::statement('RENAME TABLE ab_host_server TO supplier_host_servers'); + DB::statement('ALTER TABLE supplier_host_servers MODIFY active tinyint(1) DEFAULT NULL,MODIFY debug tinyint(1) DEFAULT NULL'); + DB::statement('ALTER TABLE supplier_host_servers MODIFY id int unsigned auto_increment,MODIFY site_id int unsigned NOT NULL,MODIFY max_accounts int unsigned DEFAULT NULL'); + DB::statement('ALTER TABLE supplier_host_servers MODIFY notes longtext DEFAULT NULL'); + + Schema::table('supplier_host_servers', function (Blueprint $table) { + $table->datetime('created_at')->nullable()->after('id'); + $table->datetime('updated_at')->nullable()->after('created_at'); + + $table->integer('supplier_id')->unsigned()->nullable(); + + $table->foreign(['site_id'])->references(['id'])->on('sites'); + $table->foreign(['supplier_id'])->references(['id'])->on('suppliers'); + }); + + DB::statement('ALTER TABLE service_host RENAME COLUMN host_server_id TO supplier_host_server_id'); + DB::statement('ALTER TABLE service_host MODIFY supplier_host_server_id int unsigned DEFAULT NULL'); + + Schema::table('service_host', function (Blueprint $table) { + $table->foreign(['supplier_host_server_id','site_id'])->references(['id','site_id'])->on('supplier_host_servers'); + }); + + DB::statement('DROP TABLE ab_domain_tld'); + //delete from ab_host_server where id=0; + //alter table service_host modify host_server_id int unsigned default null; + //update service_host set host_server_id=NULL where host_server_id=0 + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + abort(500,'Cant go back'); + } +}; diff --git a/public/css/fixes.css b/public/css/fixes.css index 344a045..5bd3062 100644 --- a/public/css/fixes.css +++ b/public/css/fixes.css @@ -110,4 +110,22 @@ span.select2-selection.select2-selection--single > span.select2-selection__rende .card-header.bg-dark .nav-pills .nav-link:not(.active):hover { background-color: #6c757d; color: #ffffff; +} + +/* Fixes to select2, to make sure col-x widths are honoured */ +.select2-selection.select2-selection--single { + height: calc(2.25rem + 2px) !important; +} +.select2.select2-container.select2-container--default { + display: flex; + flex: 1 1 auto; +} +.select2.select2-container.select2-container--default .selection { + width: 100%; +} + +/* Render the invalid red when a select container fails validation */ +.is-invalid + .select2-container--default .select2-selection--single, +.is-invalid + .select2-container--default .select2-selection--multiple { + border: 1px solid #dc3545; } \ No newline at end of file diff --git a/resources/views/theme/backend/adminlte/service/widget/domain/update.blade.php b/resources/views/theme/backend/adminlte/service/widget/domain/update.blade.php index 90d5355..57a4b1f 100644 --- a/resources/views/theme/backend/adminlte/service/widget/domain/update.blade.php +++ b/resources/views/theme/backend/adminlte/service/widget/domain/update.blade.php @@ -1,145 +1,97 @@
Registrar Details
+ +Hosting Details
+ +