It seems like you're on the right track with your attempts to manipulate the request data within the passedValidation method of your StoreApplicationRequest FormRequest class. However, the replace method should be used to replace the entire request data array, not just a single value. Instead, you should modify the specific value within the request data and then set it back using the merge method.
Here's how you can modify the terms checkbox value within the passedValidation method:
// In FormRequest
protected function passedValidation()
{
$termsValue = $this->input('terms') == 'on' ? true : false;
$this->merge(['terms' => $termsValue]);
}
This code snippet checks if the terms input is 'on' and sets it to true or false accordingly. Then it merges this value back into the request data.
Make sure that your terms column in the database is of type BOOLEAN or a compatible type that can store true/false values.
With this change, your store method in the ApplicationController should work as expected without any further modification:
public function store(StoreApplicationRequest $request)
{
Application::create($request->validated());
return to_route('apply.success');
}
This approach keeps your validation logic within the FormRequest and avoids the need to handle it in the controller.