user()->is_admin; // Only allow admins to create/update subscores } /** * Get the validation rules that apply to the request. * * @return array|string> */ public function rules(): array { $guideId = $this->route('guide')->id; // get the guide ID from route model binding $definition = $this->route('subscore')->id ?? null; // get the guide ID from route model binding return [ 'name' => [ 'required', 'string', Rule::unique('subscore_definitions') // name must be unique on a guide, allow for the current name ->where(fn ($query) => $query->where('scoring_guide_id', $guideId)) ->ignore($definition), ], 'max_score' => ['required', 'integer'], 'weight' => ['required', 'integer'], 'for_seating' => ['sometimes', 'nullable'], 'for_advance' => ['sometimes', 'nullable'], ]; } 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 if (! auditionSetting('advanceTo')) { $this->merge(['for_seating' => true]); } } }