求解方法 在 Laravel 5.2 中不允许 http 异常



我希望表中的某些值可编辑,因此我创建了这个简单的自定义表单。但这会抛出方法不允许的 http 异常的错误。有什么帮助吗?

 <form action="{{ url('/idx-test/update-this-student/'. $student->id)}}" class="" method="POST">//changing this to put, patch does not solve the error

路线

Route::post('/idx-test/update-this-student/{id}', 'StudentController@updateThisStudent'); //again changing this to patch,or put does not help

控制器

public function updateThisStudent(StudentRequest $request, $id)
{
    $student = Student::findOrFail($id);
    $student->update($request->all());
   // return redirect('city');
   echo "updated";
}

学生申请

   public function rules()
{
    return [
        'firstname'    => 'required|alpha|min:2|max:10',
        'lastname'     => 'required|alpha|min:2|max:10',
        'bday'         => 'required|date',
        'address'      => 'required|min:10',
        'zip'          => 'required|min:4|max:10',
        'phone'        => 'required|digits:7',
        'mobile'       => 'required|digits:11',
        'email'        => 'required|email',
        'city_id'      => 'required',
        'yearlevel_id' => 'required',
        'section_id'   => 'required',
    ];
}

通过添加这一小段代码

 <input type="hidden" name="_method" value="PATCH">

我的问题解决

最新更新