diff --git a/app/Http/Requests/Quote/StoreQuoteRequest.php b/app/Http/Requests/Quote/StoreQuoteRequest.php index 735970b033..699bcd0c19 100644 --- a/app/Http/Requests/Quote/StoreQuoteRequest.php +++ b/app/Http/Requests/Quote/StoreQuoteRequest.php @@ -32,15 +32,12 @@ class StoreQuoteRequest extends Request return auth()->user()->can('create', Quote::class); } - protected function prepareForValidation() +protected function prepareForValidation() { $input = $this->all(); - if (isset($input['client_id'])) { - $input['client_id'] = $this->decodePrimaryKey($input['client_id']); - } - - $input['line_items'] = isset($input['line_items']) ? $this->cleanItems($input['line_items']) : []; + if($input['client_id']) + $input['client_id'] = $this->decodePrimaryKey($input['client_id']); if(isset($input['client_contacts'])) { @@ -53,7 +50,28 @@ class StoreQuoteRequest extends Request } } - + + if(isset($input['invitations'])) + { + + foreach($input['invitations'] as $key => $value) + { + + if(isset($input['invitations'][$key]['id']) && is_numeric($input['invitations'][$key]['id'])) + unset($input['invitations'][$key]['id']); + + if(isset($input['invitations'][$key]['id']) && is_string($input['invitations'][$key]['id'])) + $input['invitations'][$key]['id'] = $this->decodePrimaryKey($input['invitations'][$key]['id']); + + if(is_string($input['invitations'][$key]['client_contact_id'])) + $input['invitations'][$key]['client_contact_id'] = $this->decodePrimaryKey($input['invitations'][$key]['client_contact_id']); + + } + + } + + $input['line_items'] = isset($input['line_items']) ? $this->cleanItems($input['line_items']) : []; + //$input['line_items'] = json_encode($input['line_items']); $this->replace($input); }