1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-05 18:52:44 +01:00

Fixes for tests (#3395)

This commit is contained in:
David Bomba 2020-02-28 08:17:17 +11:00 committed by GitHub
parent 7abab22c43
commit fba88c2d62
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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);
}