I'm trying to save a checkbox group as a serialized string in my main model's database table. AudienceGroups is simply a property of my main eloquent model. If I simply do
{{Form::checkbox('AudienceGroups[]', 'preschool');}}
{{Form::checkbox('AudienceGroups[]', 'elementary');}}
with no logic in my model, then the database column is set as the string Array. If I drop the brackets and just use {{Form::checkbox('AudienceGroups', 'preschool');}} then the column is set to the value of the last checkbox, in my case "seniors".
If I serialize the array before saving the instance of my model, it saves as a serialized array like it's supposed to, but I'm having trouble getting it to repopulate the proper checkboxes on page load (from old input or from the the saved model).
How should I attack this? Serialize the array myself and then use my own logic to control the third parameter to Form::checkbox() which controls the checked status? If so, can someone help me with that bit. I attempted it with Input::old and in_array but could never get it to work.
Thanks