从多个复选框中获取值,以便输入laravel中的文本字段

I am sure this is straightforward but I need to grab whatever is selected in my checkboxes and enter all values, as text, into my text field. I am using Laravel.

Can anyone point me in the right direction please?

VIEW

<input type="checkbox" value="Item 1" name="other_info[]">
<input type="checkbox" value="Item 2" name="other_info[]">
<input type="checkbox" value="Item 3" name="other_info[]">

CONTROLLER

$user = new User;
$user->firstname = Input::get('firstname');
$user->other_info = Input::get('other_info');
$user->save();

I'm gonna assume that you want to store them in the database. My question is then "why store it as text?".

If you load the options you are presenting the user with from your db, then you can reference those fields in the db by their id's. This will improve loading time and reduce the size of your db.

Instead of getting the full names and storing those, just make a simple form macro to build the inputs with the values from the db, make sure it will pass as an array. Then Input::get the values and attach them through a pivot table, thus referencing the original option.

Also, if you ever delete an option then it will also be detached from all userprofiles. If you don't want them detached from the userprofiles but also don't want them to show up in the options, then look into soft deleting.