You can use:
Input::has('secure') like that:
If (Input::has('secure')){ $secure = 1; (Checkbox is checked) }else{
$secure = 0; (Checkbox is not checked) }
If I save the form with the checkbox ticked it saves as a 1 in the database and if I save the form with the checkbox not ticked the it saves as a NULL instead of a 0.
And I added
"secure" => Input::get("secure")
to
if($form->isValidForAdd()){
Resource::create([
"name" => Input::get("name"),
"pattern" => Input::get("pattern"),
"target" => Input::get("target"),
"secure" => Input::get("secure")
]);
and I changed
{{ Form::checkbox('secure', 'yes') }}
to
{{ Form::checkbox('secure', 1, true) }}
I solved this by changing
"secure" => Input::get("secure")
to
"secure" => (Input::has("secure")) ? true : false
and changing
{{ Form::checkbox('secure', 1, true) }}
to
{{ Form::checkbox('secure[]', 0, false) }}
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community