重定向到页面时,我收到NoMessages错误。
add.blade.php
@extends('layout.app')
@section('content')
{!! Form::open(['action' => 'AddluggageController@addconfirm','method'=>'POST']) !!}
<div class="form-group row">
<div class="col-4">
<h5 class="col-12"><b> Passenger Info</b> </h5>
<div class="col-12">
{{form::label('name'), 'Name'}}
{{form::text('name','',['class'=>'form-control '])}} <br><br>
</div>
<div class="col-12">
{{form::label('phone'), 'Phone'}}
{{form::text('phone','',['class'=>'form-control '])}}
</div>
</div>
sni</div>
{!! Form::close() !!}
@endsection
AddluggageController.php
public function addconfirm(){
return redirect('/addsuccess')->with('success', 'Saved Successfully');
}
web.php
Route :: post('/ addconfirm','AddluggageController @ addconfirm');
当我重定向时,它给了我
MethodNotAllowedHttpException
没有消息
答案 0 :(得分:0)
将您的路线方法更改为GET
:
Route::get('/addconfirm', 'AddluggageController@addconfirm');
然后在您的刀片上添加以下内容:
@if (\Session::has('success'))
{!! \Session::get('success') !!}
@endif
答案 1 :(得分:0)
根据您的评论,您需要将路线名称从addluggage
addsuccess
return redirect('/addluggage')->with('success', 'Saved Successfully');
每当您重定向时,get
都不会post
,因此请在您重定向的控制器中进行更改
public function addconfirm(){
return view('addconfirm')->with('success', 'Saved Successfully');
// here "addconfirm" is blade name as "addconfirm.blade.php" inside "resoruces/views" folder
}
您也可以从action
更改为url
{!! Form::open(['url' => '/addconfirm','method'=>'POST']) !!}