79837319

Date: 2025-12-03 20:57:36
Score: 0.5
Natty:
Report link

You can add multiple more checks to see if the data is correct with the rules you set in the statements. cheers!

Check if the number of instructors is too high

if ($data['instructors'] > $maxInstructors) {
    if ($data['participants'] > 0) {
        $errors['instructors'] = "With participants, a maximum of {$maxInstructors} instructors is allowed for {$workshopsReserved} workshop(s).";
    } else {
        $errors['instructors'] = "A maximum of {$maxInstructors} instructors is allowed for {$workshopsReserved} workshop(s).";
    }
}
if ($data['participants'] > $maxParticipants) {
    $errors['participants'] = "A maximum of {$maxParticipants} participants is allowed for {$workshopsReserved} workshop(s).";
}
if ($data['participants'] > 0 && $data['instructors'] == 0) {
    $errors['participants'] = "Participants cannot be registered without instructors.";
}
if ($errors) {
    return back()->withErrors($errors)->withInput();
}
Reasons:
  • Blacklisted phrase (1): cheers
  • Long answer (-1):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: SpaCeBoss2001