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:
@@ -19,7 +19,10 @@ class TenantController extends Controller
|
||||
|
||||
public function store(StoreTenantRequest $request): JsonResponse
|
||||
{
|
||||
$tenant = Tenant::query()->create($request->validated());
|
||||
$validated = $request->validated();
|
||||
$props = $validated['props'] ?? [];
|
||||
|
||||
$tenant = Tenant::createWithProps($validated, $props);
|
||||
|
||||
return TenantResource::make($tenant)->response()->setStatusCode(201);
|
||||
}
|
||||
@@ -31,7 +34,10 @@ class TenantController extends Controller
|
||||
|
||||
public function update(UpdateTenantRequest $request, Tenant $tenant): TenantResource
|
||||
{
|
||||
$tenant->update($request->validated());
|
||||
$validated = $request->validated();
|
||||
$props = $validated['props'] ?? [];
|
||||
|
||||
$tenant->updateWithProps($validated, $props);
|
||||
|
||||
return TenantResource::make($tenant);
|
||||
}
|
||||
|
||||
45
app/Domains/Tenant/Controllers/TenantPropController.php
Normal file
45
app/Domains/Tenant/Controllers/TenantPropController.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Tenant\Controllers;
|
||||
|
||||
use App\Domains\Tenant\Models\TenantProp;
|
||||
use App\Domains\Tenant\Requests\StoreTenantPropRequest;
|
||||
use App\Domains\Tenant\Requests\UpdateTenantPropRequest;
|
||||
use App\Domains\Tenant\Resources\TenantPropResource;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class TenantPropController extends Controller
|
||||
{
|
||||
public function index(): JsonResponse
|
||||
{
|
||||
return TenantPropResource::collection(TenantProp::query()->latest()->get())->response();
|
||||
}
|
||||
|
||||
public function store(StoreTenantPropRequest $request): JsonResponse
|
||||
{
|
||||
$tenantProp = TenantProp::query()->create($request->validated());
|
||||
|
||||
return TenantPropResource::make($tenantProp)->response()->setStatusCode(201);
|
||||
}
|
||||
|
||||
public function show(TenantProp $tenantProp): TenantPropResource
|
||||
{
|
||||
return TenantPropResource::make($tenantProp);
|
||||
}
|
||||
|
||||
public function update(UpdateTenantPropRequest $request, TenantProp $tenantProp): TenantPropResource
|
||||
{
|
||||
$tenantProp->update($request->validated());
|
||||
|
||||
return TenantPropResource::make($tenantProp);
|
||||
}
|
||||
|
||||
public function destroy(TenantProp $tenantProp): Response
|
||||
{
|
||||
$tenantProp->delete();
|
||||
|
||||
return response()->noContent();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user