【发布时间】:2020-05-22 15:36:04
【问题描述】:
我正在尝试在验证后添加帖子,并获取发布帖子的医生的姓名并将其添加到博客中。 当我单击提交添加帖子时,我收到此错误:
The GET method is not supported for this route. Supported methods: POST.
但是当我检查数据库时,我发现了帖子。
这是控制器后控制器:
public function add()
{
$blog= new blog;
$blog-> title = request('title');
$blog ->body = request('description');
$blog->author_id=request('articlemed');
$blog ->image = request('photo');
$blog-> save();
return view ('index') ;
}
这是形式:
<form action="{{ url('/add') }}" method="POST" enctype="multipart/form-data">
@csrf
<label for="">Titre de l'article</label>
<input type="text" class="form-control" name="title" id="" placeholder="Titre de l'article">
<label for=""> Description de l'article</label> </br>
<textarea name="description" id="" cols="63" rows="20"></textarea>
<label for="">Image pour l'article</label>
<input type="file" name="photo" class="form-control" id="" placeholder="Titre de l'article">
<input type="hidden" class="form-control" name="articlemed" value="{{$med->ID}}" />
<button type="submit" class="btn btn-primary"> Ajouter l'article </button>
</form>
这是 web.php :
Route::post('/add', 'postcontroller@add');
这也是认证的控制器:
public function authentification (Request $request)
{
$this->validate($request, [
'email' => 'required',
'mdp'=> 'required'
]);
$logmedecin=doc::orderBy('created_at','desc')->get() ;
$rdv=rendezvous::get();
foreach ($logmedecin as $log )
{
if (( $log->Login== $request->input('email') ) && ( $log->Password== $request->input('mdp') ))
{
return view ('/bienvenu',['med'=>$log] ,['pat'=>$rdv] );
}
}
return back()->withErrors([
'message'=> 'Emails or password not correct!'
]) ;
}
和认证的web.php:
Route::post('/bienvenu','doctor@authentification')->name('aziz');
【问题讨论】:
-
尝试像
Route::get('/add', 'postcontroller@add');那样添加一条获取路线@