I have a boolean field that is represented by 0
and 1
in my database.
if ($request->input('submitted')) {
// do code
}
This has been working because it's only been setting the field to 1
(true) but now there's a new flow that can revert the submission.
It has not been setting it back to 0
when I pass the value 0
in from the frontend and I assume it's because that condition is getting skipped since 0
would eval to null.
Is the best way to handle it:
if (isset($request->input('submitted'))) {
// do code
}
or would strictly checking against null work better:
if ($request->input('submitted') !== null) {
// do code
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire