Skip to content

Commit 7e1b477

Browse files
committed
Fix failing test ensuring company id is an integer
1 parent 979e450 commit 7e1b477

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

app/Http/Requests/StoreAssetRequest.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,18 @@ public function authorize(): bool
2626

2727
public function prepareForValidation(): void
2828
{
29+
// Guard against users passing in an array for company_id instead of an integer.
30+
// If the company_id is not an integer then we simply use what was
31+
// provided to be caught by model level validation later.
32+
$idForCurrentUser = is_int($this->company_id)
33+
? Company::getIdForCurrentUser($this->company_id)
34+
: $this->company_id;
35+
2936
$this->parseLastAuditDate();
3037

3138
$this->merge([
3239
'asset_tag' => $this->asset_tag ?? Asset::autoincrement_asset(),
33-
'company_id' => Company::getIdForCurrentUser($this->company_id),
40+
'company_id' => $idForCurrentUser,
3441
'assigned_to' => $assigned_to ?? null,
3542
]);
3643
}

0 commit comments

Comments
 (0)