I have show_header
and show_footer
fields in the database, the value can be 1 or 0.
<input type="checkbox" name="show_header" checked="checked" value="1">
<input type="checkbox" name="show_footer" checked="checked" value="1">
Assume show_header
and show_footer
is set to 1 in the database and you uncheck the both of them in the form, the request inputs will not contain show_header
and show_footer
fields because it is not selected.
So how can I get around this to update show_header
and show_footer
to 0 in the database?
Example :
$page = Page::where('user_id', 1);
$page->update($request->all());
If you do:
dd($request->all())
You will not find show_header
and show_footer
since checkboxes are not checked, so by doing $page->update($request->all());
it can't set show_header
and show_header
to 0 in the database.