dimanche 6 décembre 2015

Laravel eloquent query not updating checkbox input

Why does the following hard coded eloquent query work:

Auth::user()->update(['text_only_email' => true ]);

But when the data comes via a form checkbox input it always updates as false even when the input is true ?

$data['text_only_email'] = $request->input('text_only_email', false);
Auth::user()->update($data);

See results from die and dump to prove the incoming value is true:

$data['text_only_email'] = $request->input('text_only_email', false);

dd($data);

Results of dump:

array:1 [▼
  "text_only_email" => "true"
]

Aucun commentaire:

Enregistrer un commentaire