Refactor TenantController to use createWithProps and updateWithProps methods for improved property synchronization
This commit is contained in:
@@ -23,8 +23,7 @@ class TenantController extends Controller
|
|||||||
$props = $validated['props'] ?? [];
|
$props = $validated['props'] ?? [];
|
||||||
unset($validated['props']);
|
unset($validated['props']);
|
||||||
|
|
||||||
$tenant = Tenant::create($validated);
|
$tenant = Tenant::createWithProps($validated, $props);
|
||||||
$tenant->syncPropValues($props);
|
|
||||||
|
|
||||||
return TenantResource::make($tenant)->response()->setStatusCode(201);
|
return TenantResource::make($tenant)->response()->setStatusCode(201);
|
||||||
}
|
}
|
||||||
@@ -40,8 +39,7 @@ class TenantController extends Controller
|
|||||||
$props = $validated['props'] ?? [];
|
$props = $validated['props'] ?? [];
|
||||||
unset($validated['props']);
|
unset($validated['props']);
|
||||||
|
|
||||||
$tenant->update($validated);
|
$tenant = $tenant->updateWithProps($validated, $props);
|
||||||
$tenant->syncPropValues($props);
|
|
||||||
|
|
||||||
return TenantResource::make($tenant);
|
return TenantResource::make($tenant);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user