This commit is contained in:
@@ -23,6 +23,15 @@ final class ExistingBusinessDrafts
|
||||
$data = Validator::make($input, [
|
||||
'modality' => ['required', 'in:'.implode(',', self::MODALITIES)],
|
||||
'sector_id' => ['sometimes', 'nullable', 'integer', Rule::exists('sectors', 'id')->whereNull('deleted_at')->where('is_active', true)],
|
||||
'public_title' => ['sometimes', 'nullable', 'string', 'max:180'],
|
||||
'activity_code' => ['sometimes', 'nullable', 'string', 'max:60'],
|
||||
'stage' => ['sometimes', 'nullable', 'string', 'max:40'],
|
||||
'objective' => ['sometimes', 'nullable', 'string', 'max:5000'],
|
||||
'currency' => ['sometimes', 'nullable', 'regex:/^[A-Z]{3}$/', 'required_with:amount_min,amount_max'],
|
||||
'amount_min' => ['sometimes', 'nullable', 'numeric', 'min:0', 'max:999999999999999999.99'],
|
||||
'amount_max' => ['sometimes', 'nullable', 'numeric', 'min:0', 'gte:amount_min', 'max:999999999999999999.99'],
|
||||
'available_percentage' => ['sometimes', 'nullable', 'numeric', 'between:0,100'],
|
||||
'funds_use' => ['sometimes', 'nullable', 'string', 'max:10000'],
|
||||
'classification' => ['required', 'in:internal,confidential,restricted'],
|
||||
'version_no' => [$id ? 'required' : 'prohibited', 'integer', 'min:1'],
|
||||
'reason' => ['required', 'string', 'min:10', 'max:1000'],
|
||||
@@ -56,6 +65,11 @@ final class ExistingBusinessDrafts
|
||||
$business->status = 'draft';
|
||||
}
|
||||
$business->fill(['modality' => $data['modality'], 'classification' => $data['classification'], 'payload' => $data['payload']]);
|
||||
foreach (['public_title', 'activity_code', 'stage', 'objective', 'currency', 'amount_min', 'amount_max', 'available_percentage', 'funds_use'] as $field) {
|
||||
if (array_key_exists($field, $data)) {
|
||||
$business->{$field} = $data[$field];
|
||||
}
|
||||
}
|
||||
if (array_key_exists('sector_id', $data)) {
|
||||
$business->sector_id = $data['sector_id'];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user