Back

Saving checkbox value in to a database


My form:

{{ Form::checkbox('portfolio', 0, false) }}

By default checkbox is unchecked. In controller i am getting the value of checkbox this way:

Input::get('portfolio');

Is that a right way?

Then in my model:

$page->portfolio = $input['portfolio'];

but it doesn't save a checkbox value in database table "portfolio" (boolean type), it always has 0 value, even if i check the checkbox.

heihachi88 replied 3 years ago Solution

Solved this way:

(Input::has('portfolio')) ? true : false;

looks like

Input::get('portfolio');

returns nothing in case with checkbox.

asadi20 replied 6 months ago

thank you, it's work for me


Sign in to participate in this thread!



We'd like to thank these amazing companies for supporting us