fix: Remove undefined businesses() relation call in AssetAccountController
- Fixed 500 error on POST /api/asset-accounts/wizard - business_id is now optional and only set if provided in request - Previously tried to call User::businesses() which doesn't exist
This commit is contained in:
parent
a90ff9d013
commit
6a86b2627d
@ -283,7 +283,10 @@ public function storeWithWizard(Request $request): JsonResponse
|
||||
// Criar o ativo
|
||||
$data = $validator->validated();
|
||||
$data['user_id'] = Auth::id();
|
||||
$data['business_id'] = $request->business_id ?? Auth::user()->businesses()->first()?->id;
|
||||
// business_id é opcional e vem do request se fornecido
|
||||
if ($request->filled('business_id')) {
|
||||
$data['business_id'] = $request->business_id;
|
||||
}
|
||||
$data['status'] = 'active';
|
||||
|
||||
$asset = AssetAccount::create($data);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user