feat(tenant): reintroduce tenant-specific props and instance values

Restore props support only for the Tenant domain using a tenant-scoped model
instead of the removed generic Prop/Propable implementation.

Add tenant prop definitions and instance values:
- add TenantProp and TenantPropValue models
- add tenant-only data type enum and prop validation rules
- add migrations for tenant_props and tenant_prop_values tables
- persist prop values by tenant_codigo + tenant_prop_codigo

Expose tenant prop management through the Tenant domain:
- add TenantPropController with CRUD endpoints
- add Store/Update request classes for tenant prop definitions
- register tenant-props routes

Re-enable tenant prop syncing and serialization:
- restore createWithProps/updateWithProps flows in Tenant
- validate props on tenant create/update requests
- include collapsed props in TenantResource
- keep the implementation scoped to Tenant without reintroducing polymorphic props

Add coverage for the new tenant prop behavior:
- update bootstrap tenant feature test to assert prop values
- add feature tests for tenant prop creation and validation
This commit is contained in:
2026-06-24 14:50:58 -03:00
parent 75129b7552
commit 689d115a8f
18 changed files with 586 additions and 6 deletions

View File

@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('tenant_props', function (Blueprint $table) {
$table->id();
$table->string('codigo')->unique();
$table->string('nombre');
$table->text('descripcion')->nullable();
$table->boolean('is_required')->default(false);
$table->string('data_type');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('tenant_props');
}
};

View File

@@ -0,0 +1,44 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('tenant_prop_values', function (Blueprint $table) {
$table->id();
$table->string('tenant_codigo');
$table->string('tenant_prop_codigo');
$table->text('value')->nullable();
$table->timestamps();
$table->foreign('tenant_codigo')
->references('codigo')
->on('tenants')
->cascadeOnUpdate()
->cascadeOnDelete();
$table->foreign('tenant_prop_codigo')
->references('codigo')
->on('tenant_props')
->cascadeOnUpdate()
->cascadeOnDelete();
$table->unique(['tenant_codigo', 'tenant_prop_codigo']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('tenant_prop_values');
}
};