在laravel 5.1中,它给出了错误UNDEFINED INDEX :: cost_group
我想在其他付款视图页面中显示课程表的列名,并在选择其中一个时将其存储到另一个表(付款)中
我的PaymentsController.php
:
public function index(Request $request) {
$filter = $request->input();
$sort = $request->query();
$payments = Payment::filter($filter)->sort($sort)->paginate(10);
foreach(Course::all() as $course) {
$data['courses'][$course->id] = $course->name;
$data['courses'][$course->cost_group]=$course->course_cost;
$data['courses'][$course->cost_minigroup]=$course->course_name;
$data['courses'][$course->cost_individual]=$course->course_name;
}
return view('payments.index', compact('payments', 'data'));
}
我的form.blade.php(付款)
<div class="ui form">
<div class="field">
<div class="ui selection dropdown">
<input type="hidden" name="amount" id="course_val" />
<i class="dropdown icon"></i>
<div class="default text">Course type</div>
<div class="menu">
<div class="item course_val" data-value="{{$data['cost_group']}}">Group</div>
<div class="item course_val" data-value="{{$data['cost_minigroup']}}">Minigroup</div>
<div class="item course_val" data-value="{{$data['cost_individual']}}">Individual</div>
</div>
</div>
</div>
</div>