Can you post the result of:
dd($request->all());
I have a controller, wich has got the logic for a form-group. This form-group has two checkboxes and i store the valuer in an Sqlie3 database. (There are booleans represented as TinyInt-s, and these can store the value of 0 and 1.
I try to represent this problem in my controller like this, but it won't set the proper 0 or 1 digits in the database. What am i doing wrong?
The checkbox values are stored in $request->elintezve ans $request->ugyfelnek_kiadva.
public function feluliras (Request $request, $id)
{
$update = MainNumbers::find($id);
$update->foszam = $request->foszam;
$update->ev = $request->ev;
$update->elso_szemely = $request->elso_szemely;
$update->masodik_szemely = $request->masodik_szemely;
$update->ugytargy = $request->ugytargy;
$update->berkezett = $request->beerkezett;
if ($request->elintezve) {
$update->elintezve = 1;
} else {
$update->elintezve = 0;
}
if (!$request->ugyfelnek_kiadva) {
$update->ugyfelnek_kiadva = 1;
} else {
$update->ugyfelnek_kiadva = 0;
}
$update->save();
return view('master');
}
you dont need to do if else..
just do:
$update->elintezve = $request->elintezve ?? 0
checkbox values as you realise do not get posted if users dont check them.. so there could be something wrong with spelling ie in your controller vs how you called them in your form.. really need to see form code for checkboxes (& as the above said a dd() )
Please or to participate in this conversation.