我有这个有textarea的表单。我应该输入消息并显示内容。但是,我收到此错误MethodNotAllowedHttpException in RouteCollection.php line 218:
我想不出解决问题的方法。我已尝试使用put但得到相同的行错误。
以下是我的代码 我的刀片:
<form class="form-horizontal" role="form" method="post" action="sendbulk">
{{ csrf_field() }}
<div class="form-group">
<label for="message" class="col-sm-1 control-label">Message</label>
<div class="col-sm-6">
<textarea class="form-control" rows="4" name="message" required placeholder="Message"></textarea>
</div>
</div>
<div class="form-group">
<div class="col-sm-6 col-sm-offset-1">
<input id="submit" name="submit" type="submit" value="Send" class="btn btn-primary pull-right">
<a href="/sendsms" class="btn btn-default pull-left">
<i class="fa fa-arrow-left" aria-hidden="true"></i> Cancel </a>
</div>
</div>
</form>
我的路线:
Route::get('/', function () {
return view('welcome');
});
Auth::routes();
Route::get('/home', 'HomeController@index');
Route::get('/receipts', 'HomeController@receipt');
Route::post('sendreceipt/{id}','HomeController@setReceipt');
Route::get('/sendsms', 'SmsController@send');
Route::post('/sendbulk', 'SmsController@sendsms');
Route::post('/selectContacts','SmsController@SelectContacts');
Route::get('/registerUsers', 'UsersController@Register');
Route::get('/companyprofile', 'UsersController@Company');
Route::post('/companyProfile', 'UsersController@companyProfile');
Route::get('/view-most-valuable-customers', 'HomeController@valuable');
Route::get('users', ['as' => 'UsersController', 'uses' => 'UsersController@getIndex']);
Route::get('users-data', ['as' => 'UsersControllerUsersData', 'uses' => 'UsersController@Users']);
Route::get('/settings', 'SettingsController@index');
Route::get('/admin', 'adminController@dashboard');
Route::get('payments', ['as' => 'HomeController', 'uses' => 'HomeController@getIndex']);
Route::get('payments-data', ['as' => 'HomeControllerPaymentsData', 'uses' => 'HomeController@Payments']);
Route::get('sms', ['as' => 'SmsController', 'uses' => 'SmsController@getIndex']);
Route::get('Sms-data', ['as' => 'SmsControllerSmsData', 'uses' => 'SmsController@Sms']);
Route::get('logs', ['as' => 'LogsController', 'uses' => 'LogsController@getIndex']);
Route::get('Logs-data', ['as' => 'LogsControllerLogsData', 'uses' => 'LogsController@logs']);
我的控制器:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Validator,Auth, DB;
use App\Http\Requests;
use Yajra\Datatables\Facades\Datatables;
class SmsController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
}
public function sendsms(Request $request){
$message=$request->messsage;
$validator = Validator::make($request->all(), [
'messsage' => 'required|max:160',]);
if ($validator->fails()) {
return redirect('/selectContacts')
->withErrors($validator)
->withInput();}
echo $message;
}
}
有人会友好地指出我为什么会收到此错误? 错误:
MethodNotAllowedHttpException in RouteCollection.php line 218:
in RouteCollection.php line 218
at RouteCollection->methodNotAllowed(array('POST')) in RouteCollection.php line 205
at RouteCollection->getRouteForMethods(object(Request), array('POST')) in RouteCollection.php line 158
at RouteCollection->match(object(Request)) in Router.php line 755
at Router->findRoute(object(Request)) in Router.php line 610
at Router->dispatchToRoute(object(Request)) in Router.php line 596
at Router->dispatch(object(Request)) in Kernel.php line 267
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 46
答案 0 :(得分:0)
您可以更新路线以删除第一个斜杠吗?
Route::post('sendbulk', 'SmsController@sendsms');