我正在尝试从表单中使用course_1, course_2将学生信息存储在数据库id, name中。同一学生不能再次注册同一课程。
Students Table
id name
1 X
2 Y
Courses Table
id course_name
1 A
2 B
Student_courses Table
student_id courses_id
1 1
2 1
2 2
像这样的学生控制器:
public function studentRegistration(Request $request)
我刚来Laravel,所以很抱歉我的新手问题:
我有在输入字段,它必须是有效的,只有当它是零或如果它的值存在于“产品”数据库表中。我在Laravel 5.2中使用表单请求验证。
这是我的代码:
class CreateRequest extends Request
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;