POST 此路由不支持方法。支持的方法:GET、HEAD
POST method is not supported for this route. Supported methods: GET, HEAD
我想制作我的病历预约。我正在使用 2 个控制器:PatientController 和 AppointmentController。
PatientController.php
public function book()
{
$patients = new User();
return view('patient.patient_book', compact('patients'));
}
AppointmentController.php
public function store(){
$patient = new User();
$appointment = new Appointment();
$appointment->user_id = $patient->id;
$appointment->appointment_date = request('date_booking');
$appointment->slot = request('slot');
$appointment->branch = request('branch');
$appointment->note = request('note');
$appointment->save();
return redirect('/patient/report_list');
}
至于我的路线;
Route::prefix('patient')->group(function(){
Route::get('/patient_book', 'PatientController@book');
Route::post('/report_list', "AppointmentController@store");
});
我还在用户模型
中包含了关系
protected $guarded = [];
public function appointments(){
return $this->hasMany(Appointment::class);
}
以及约会模型;
protected $guarded = [];
public function patient(){
return $this->belongsTo(User::class);
}
我的patient_book.blade.php;
<form method = "POST" action = "/patient/report_list">
提交表单后,需要将其重定向到 report_list.blade.php,新提交的约会将列在该页面上。我遵循了 Laracasts 中的教程,其中使用的示例是项目和任务。但是,当我尝试 运行 时收到此错误。
The POST method is not supported for this route. Supported methods: GET, HEAD.
我检查了其他答案,但似乎没有任何帮助。请帮助我,因为我还是新手并且对 Laravel 感到困惑。谢谢。
错误在这里
return redirect('/patient/report_list');
您不能 return 对 POST 路由的 301 重定向响应,它必须是 GET 路由
您可能想要重定向到上一页
return back();
希望对您有所帮助
我想制作我的病历预约。我正在使用 2 个控制器:PatientController 和 AppointmentController。
PatientController.php
public function book()
{
$patients = new User();
return view('patient.patient_book', compact('patients'));
}
AppointmentController.php
public function store(){
$patient = new User();
$appointment = new Appointment();
$appointment->user_id = $patient->id;
$appointment->appointment_date = request('date_booking');
$appointment->slot = request('slot');
$appointment->branch = request('branch');
$appointment->note = request('note');
$appointment->save();
return redirect('/patient/report_list');
}
至于我的路线;
Route::prefix('patient')->group(function(){
Route::get('/patient_book', 'PatientController@book');
Route::post('/report_list', "AppointmentController@store");
});
我还在用户模型
中包含了关系protected $guarded = [];
public function appointments(){
return $this->hasMany(Appointment::class);
}
以及约会模型;
protected $guarded = [];
public function patient(){
return $this->belongsTo(User::class);
}
我的patient_book.blade.php;
<form method = "POST" action = "/patient/report_list">
提交表单后,需要将其重定向到 report_list.blade.php,新提交的约会将列在该页面上。我遵循了 Laracasts 中的教程,其中使用的示例是项目和任务。但是,当我尝试 运行 时收到此错误。
The POST method is not supported for this route. Supported methods: GET, HEAD.
我检查了其他答案,但似乎没有任何帮助。请帮助我,因为我还是新手并且对 Laravel 感到困惑。谢谢。
错误在这里
return redirect('/patient/report_list');
您不能 return 对 POST 路由的 301 重定向响应,它必须是 GET 路由
您可能想要重定向到上一页
return back();
希望对您有所帮助