Fix failing test ensuring company id is an integer

This commit is contained in:
Marcus Moore 2024-10-17 15:18:41 -07:00
parent 979e4502ff
commit 7e1b47708e
No known key found for this signature in database

View file

@ -26,11 +26,18 @@ class StoreAssetRequest extends ImageUploadRequest
public function prepareForValidation(): void
{
// Guard against users passing in an array for company_id instead of an integer.
// If the company_id is not an integer then we simply use what was
// provided to be caught by model level validation later.
$idForCurrentUser = is_int($this->company_id)
? Company::getIdForCurrentUser($this->company_id)
: $this->company_id;
$this->parseLastAuditDate();
$this->merge([
'asset_tag' => $this->asset_tag ?? Asset::autoincrement_asset(),
'company_id' => Company::getIdForCurrentUser($this->company_id),
'company_id' => $idForCurrentUser,
'assigned_to' => $assigned_to ?? null,
]);
}