简体   繁体   中英

< select name=“options” multiple > How to store in DB with Laravel

How would I store <option > 's in a multiple select like so <select name="options" multiple> with my database i'm guessing something like json, but I'm unsure.

To then save it from my controller has

$options = Input::get('options');

How would one do this ?

Help greatly appreciated.

Generally you would have:

  • a table containing your free form results
  • a table containing all the options that can be selected from
  • a junction table

The junction table would generally have two columns. Each would be a foreign key. One would match the id of the row in the first table. One would match the id of the second table. Together they would form a compound primary key.

See wikipedia: Junction table for more details.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM