@phayes0289 I always use unsignedTinyInteger() for bool type, it is really hard to query bit type
or you can use $table->boolean('confirmed'); it is equal TINYINT(1)
I have a select input that has two options.... yes and no. The value passed to the controller is a "0" (zero) or a "1". I am trying to save it to a boolean field in MySQL. Here is the update method I am using:
public function update(Request $request, PibsFeature $pibsFeature)
{
$formFields = $request->validate([
'pibs_id' => ['required'],
'title' => ['required', 'min:3'],
'type' => ['required', 'min:3'],
'tags' => ['nullable'],
'description' => ['required'],
'image' => ['nullable'],
'enable_map' => ['required']
]);
$pibsFeature->update($formFields);
$pibsFeature->save();
$pibs = pibs::find($request->pibs_id);
return redirect()->route('pibs.features.index',compact('pibs'))->with('message', 'Your collection has been created saved!');
}
When the data gets submitted, it causes the following SQL error, which I assume is from converting the 1 or 0 into a binary value?:
SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'enable_map' at row 1
How do I convert the value so it can be stored in MySQL as a "bit" field.... or should I do something else altogether?
TIA
Please or to participate in this conversation.