When you need to validate a field, but don't actually require it for anything e.g. 'accept terms and conditions', make use of the exclude
rule. That way, the validated
method won't return it...
class StoreRequest extends FormRequest{ public function rules(): array { return [ 'name' => 'required|string', 'email_address' => 'required|email', 'terms_and_conditions' => 'required|accepted|exclude', ]; }
class RegistrationController extends Controller{ public function store(StoreRequest $request) { $payload = $request->validated(); // only name and email $user = User::create($payload); Auth::login($user); return redirect()->route('dashboard'); }
Tip given by @mattkingshott