1 回答
TA贡献1777条经验 获得超10个赞
对于表单动作,
@if (\Auth::check())
@if ($course->students()->where('user_id', \Auth::id())->count() == 0)
{{Form::open(['action'=> 'CoursesController@payment', 'method' => 'POST'])}}
<div class="form-group">
<input type="hidden" name="course_id" value="{{ $course->id }}"/>
</div>
{{Form::submit('Enroll', ['class'=>'btn btn-primary'])}}
{{Form::close()}}
@endif
@else
对于控制器:
public function payment(Request $request) {
$course = Course::findOrFail($request->get('course_id'));
$course->students()->attach(\Auth::id());
return redirect()->back()->with('success', 'Payment completed successfully.');
}
- 1 回答
- 0 关注
- 123 浏览
添加回答
举报