2017-10-21 84 views
-1

我試圖做一個聯繫形式Laravel 當我提交我得到這個錯誤 消息我主要新laravel,所以我不知道爲什麼它的出現聯繫表錯誤MethodNotAllowedHttpException

routes.php文件

Route::post('/contact/sendmail', [ 
    'uses' => '[email protected]', 
    'as'  => 'contact.send' 
]); 

ContactMessageController.php

class ContactMessageController extends Controller 
{ 

    public function postSendMessage(Request $request) 
    { 
     $this->validate($request, [ 
      'email' => 'required|email', 
      'name' => 'required|max:100', 
      'subject' => 'required|max:140', 
      'message' => 'required|min:10' 
     ]); 
     $message = new ContactMessage(); 
     $message->email = $request['email']; 
     $message->sender = $request['name']; 
     $message->subject = $request['subject']; 
     $message->body = $request['message']; 
     $message->save(); 
     return redirect()->route('contact')->with(['success' => 'Message Succesfully sent']); 
    } 
} 

contact.blade.php

@extends ('layouts.master') 

@section('title') 
    Contact 
@endsection 

@section('styles') 
    <link rel="stylesheet" href="{{ URL::secure('src/css/form.css') }}" /> 
@endsection 

@section('content') 
    @include('includes.info-box') 
    <form action="{{ route('contact.send') }}" mathod="post" id="contact-form"> 
     <div class="input-group"> 
      <label for="name">Your Name</label> 
      <input type="text" name="name" id="name" value="{{ Request::old('name') }}" /> 
     </div> 
     <div class="input-group"> 
      <label for="email">Your E-Mail</label> 
      <input type="text" name="email" id="email" value="{{ Request::old('email') }}" /> 
     </div> 
     <div class="input-group"> 
      <label for="subject">Subject</label> 
      <input type="text" name="subject" id="subject" value="{{ Request::old('subject') }}" /> 
     </div> 
     <div class="input-group"> 
      <label for="message">Your Message</label> 
      <textarea name="message" id="message" rows="10">{{ Request::old('message') }}</textarea> 
     </div> 
     <button type="submit" class="btn">Submit Message</button> 
     <input type="hidden" value="{{ Session::token() }}" name="_token" /> 
    </form> 
@endsection 

我找不到爲什麼我得到這個錯誤

MethodNotAllowedHttpException in RouteCollection.php line 218: 
+0

你在mathod =「post」中有一個拼寫錯誤,它應該是method =「post」 –

+0

哎呀,這是它謝謝 –

回答

1

只是一個錯字。您需要將mathod="post"更改爲method="post"