Refactor TenantController to use createWithProps and updateWithProps methods for improved property synchronization
This commit is contained in:
parent
8e5814e333
commit
b2c8f13d2e
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue