Correct issue where a subscore could not be created for seating only.
This commit is contained in:
parent
0ca239d297
commit
956d70a90e
|
|
@ -86,7 +86,6 @@ class ScoringGuideController extends Controller
|
||||||
$validateData['for_advance'] = 0;
|
$validateData['for_advance'] = 0;
|
||||||
$validateData['for_seating'] = 1;
|
$validateData['for_seating'] = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
SubscoreDefinition::create([
|
SubscoreDefinition::create([
|
||||||
'scoring_guide_id' => $guide->id,
|
'scoring_guide_id' => $guide->id,
|
||||||
'name' => $validateData['name'],
|
'name' => $validateData['name'],
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,15 @@ class SubscoreDefinitionRequest extends FormRequest
|
||||||
*
|
*
|
||||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||||
*/
|
*/
|
||||||
|
protected function prepareForValidation()
|
||||||
|
{
|
||||||
|
// Handle checkboxes
|
||||||
|
$this->merge([
|
||||||
|
'for_seating' => $this->has('for_seating') ? true : false,
|
||||||
|
'for_advance' => $this->has('for_advance') ? true : false,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
public function rules(): array
|
public function rules(): array
|
||||||
{
|
{
|
||||||
$guideId = $this->route('guide')->id; // get the guide ID from route model binding
|
$guideId = $this->route('guide')->id; // get the guide ID from route model binding
|
||||||
|
|
@ -36,19 +45,13 @@ class SubscoreDefinitionRequest extends FormRequest
|
||||||
],
|
],
|
||||||
'max_score' => ['required', 'integer'],
|
'max_score' => ['required', 'integer'],
|
||||||
'weight' => ['required', 'integer'],
|
'weight' => ['required', 'integer'],
|
||||||
'for_seating' => ['sometimes', 'nullable'],
|
'for_seating' => ['boolean'],
|
||||||
'for_advance' => ['sometimes', 'nullable'],
|
'for_advance' => ['boolean'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function passedValidation()
|
protected function passedValidation()
|
||||||
{
|
{
|
||||||
// Normalize the boolean inputs
|
|
||||||
$this->merge([
|
|
||||||
'for_seating' => $this->has('for_seating') ? (bool) $this->input('for_seating') : false,
|
|
||||||
'for_advance' => $this->has('for_advance') ? (bool) $this->input('for_advance') : false,
|
|
||||||
]);
|
|
||||||
|
|
||||||
// Apply your custom logic
|
// Apply your custom logic
|
||||||
if (! auditionSetting('advanceTo')) {
|
if (! auditionSetting('advanceTo')) {
|
||||||
$this->merge(['for_seating' => true]);
|
$this->merge(['for_seating' => true]);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue