【发布时间】:2015-05-22 06:06:32
【问题描述】:
我想获取下拉列表的选定值。
下拉列表包含我数据库中的一个表
这是我的下拉列表
<div class="form-group">
{{ Form::label('student_name', 'Assign a Student to this section:') }}
{{ Form::select('firstname', $users, null) }}
</div>
<div class="form-group">
{{ Form::label('teacher_name', 'Assign a Teacher to this section:') }}
{{ Form::select('firstname', $users1, null) }}
</div>
现在,我要获取选中的值
这是我插入记录的位置
foreach(User::where('isTeacher', '0')->where('isAdmin', '0')->get() as $student)
foreach(User::where('isTeacher', '1')->where('isAdmin', '0')->get() as $teacher)
$section = new Section1();
$section->name = Input::get('name');
$section->student_id = $student->id;
$section->student_firstname = $student->firstname;
$section->teacher_id = $teacher->id;
$section->teacher_firstname = $teacher->firstname;
你可能在想我为什么使用 foreach。 到目前为止,我使用我过去的代码作为创建用户的参考,效果很好。
现在,我又用它来录制一段了。
如果您能向我推荐除 foreach 之外的其他代码,我将不胜感激 :)
请帮助大家T_T谢谢。
【问题讨论】:
标签: laravel laravel-4 eloquent declaration laravel-5