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:


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.

  • 2 years ago

Solved this way:

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

looks like


returns nothing in case with checkbox.

thank you, it's work for me