diff --git a/app/Domains/Client/Models/Client.php b/app/Domains/Client/Models/Client.php index e0bf9e1..4bf501b 100644 --- a/app/Domains/Client/Models/Client.php +++ b/app/Domains/Client/Models/Client.php @@ -2,7 +2,6 @@ namespace App\Domains\Client\Models; -use App\Domains\Integration\Models\ClientIntegration; use App\Domains\Tenant\Models\Tenant; use Illuminate\Database\Eloquent\Attributes\Fillable; use Illuminate\Database\Eloquent\Model; @@ -21,10 +20,4 @@ class Client extends Model { return $this->hasMany(Tenant::class); } - - /** @return HasMany */ - public function integrations(): HasMany - { - return $this->hasMany(ClientIntegration::class); - } } diff --git a/app/Domains/Client/Resources/ClientResource.php b/app/Domains/Client/Resources/ClientResource.php index f2e13bc..caf724e 100644 --- a/app/Domains/Client/Resources/ClientResource.php +++ b/app/Domains/Client/Resources/ClientResource.php @@ -20,7 +20,6 @@ class ClientResource extends JsonResource 'codigo' => $tenant->codigo, 'nombre' => $tenant->nombre, 'dominio' => $tenant->dominio, - 'base_path' => $tenant->base_path, ])), ]; } diff --git a/database/migrations/2026_08_18_040000_create_clients_and_assign_tenants.php b/database/migrations/2026_08_18_040000_create_clients_and_assign_tenants.php index 69269dc..94f623f 100644 --- a/database/migrations/2026_08_18_040000_create_clients_and_assign_tenants.php +++ b/database/migrations/2026_08_18_040000_create_clients_and_assign_tenants.php @@ -9,35 +9,27 @@ return new class extends Migration { public function up(): void { - if (! Schema::hasTable('clients')) { - Schema::create('clients', function (Blueprint $table): void { - $table->id(); - $table->string('code')->unique(); - $table->string('name'); - $table->timestamps(); - }); - } + Schema::create('clients', function (Blueprint $table): void { + $table->id(); + $table->string('code')->unique(); + $table->string('name'); + $table->timestamps(); + }); - if (! Schema::hasColumn('tenants', 'client_id')) { - Schema::table('tenants', function (Blueprint $table): void { - $table->foreignId('client_id')->nullable()->after('id')->constrained('clients')->restrictOnDelete(); - }); - } + Schema::table('tenants', function (Blueprint $table): void { + $table->foreignId('client_id')->nullable()->after('id')->constrained('clients')->restrictOnDelete(); + }); DB::table('tenants') ->select(['id', 'codigo', 'nombre', 'created_at', 'updated_at']) ->orderBy('id') ->each(function (object $tenant): void { - $clientId = DB::table('clients')->where('code', $tenant->codigo)->value('id'); - - if ($clientId === null) { - $clientId = DB::table('clients')->insertGetId([ - 'code' => $tenant->codigo, - 'name' => $tenant->nombre, - 'created_at' => $tenant->created_at ?? now(), - 'updated_at' => $tenant->updated_at ?? now(), - ]); - } + $clientId = DB::table('clients')->insertGetId([ + 'code' => $tenant->codigo, + 'name' => $tenant->nombre, + 'created_at' => $tenant->created_at ?? now(), + 'updated_at' => $tenant->updated_at ?? now(), + ]); DB::table('tenants')->where('id', $tenant->id)->update(['client_id' => $clientId]); });