fill(Arr::except($request->validated(), 'file')); if ($request->filled('file')) { $claimModel->file = FileHelper::storeBase64File( tableName: 'claim', fileBase64: $request->file, private: true, ); } // Add brand id from service. $claimModel->brand_id = $service->brand->getKey(); // Add customer relation if exist. $crmCustomer = CustomerInfo::getFromEmail($claimModel->brand, $claimModel->email)->first(); if (!is_null($crmCustomer)) { $claimModel->hashcode = $crmCustomer->hashcode; } if (!$claimModel->saveOrFail()) { throw new CrmException('Api failed to store claim.'); } $claimModel->brand()->associate($service->brand); return response()->json(); } }