联系表格Laravel 5.4

时间:2017-05-11 22:41:07

标签: php laravel laravel-5

我试图在Laravel 5.4中建立联系表格。我几乎成功了但除了实际的消息之外,在我的邮件中我得到了页面的结构(看截图)。你能帮帮我吗? enter image description here

我的观看表格:

                <div class="row">

      {{ Form:: open(array('action' => 'ContactController@getContactUsForm')) }}

      <ul class="errors">
      @foreach($errors->all('<li>:message</li>') as $message)
      {{ $message }}
      @endforeach
      </ul>

      <div class="form-group">
      {{ Form:: textarea ('message', '', array('placeholder' => 'Message', 'class' => 'form-control', 'id' => 'message', 'rows' => '7' )) }}
      </div>




      <div class="modal-footer">
      {{ Form::submit('Submit', array('class' => 'btn btn-primary')) }}
      {{ Form:: close() }}


      </div>
            </div>

我的控制器:

namespace App\Http\Controllers;
use Input;
use Illuminate\Http\Request;
use Validator;
use Mail;
use Redirect;

class ContactController extends Controller
{
public function getContactUsForm(Request $request){
    //Get all the data and store it inside Store Varible
    $data = \Input::all();
    //$data = $request->message;
    //$data = $request->input('message');

    //Validation rules
    $rules = array (
        //'first_name' => 'required', uncomment if you want to grab this field
        //'email' => 'required|email',  uncomment if you want to grab this field
        'message' => 'required|min:5'
    );

    //Validate data
    $validator = Validator::make ($data, $rules);

    //If everything is correct than run passes.
    if ($validator -> passes()){



     Mail::send('support/contact', $data, function($message) use ($data)
            {
                //$message->from($data['email'] , $data['first_name']); uncomment if using first name and email fields
                $message->from('masha@mail.com', 'contact form');
    //email 'To' field: cahnge this to emails that you want to be notified.
    $message->to('masha@mail.com', 'Masha')->subject('Contact Form');

            });
            // Redirect to page
   return Redirect::route('contact')
    ->with('message', 'Your message has been sent. Thank You!');


            //return View::make('contact');
         }else{
   //return contact form with errors
            return Redirect::route('contact')
             ->with('error', 'Feedback must contain more than 5 characters. Try Again.');

     }
 }
}

1 个答案:

答案 0 :(得分:0)

改变这个:

<div class="modal-footer">
  {{ Form::submit('Submit', array('class' => 'btn btn-primary')) }}
  {{ Form:: close() }}
</div>

对此:

<div class="modal-footer">
  {{ Form::submit('Submit', array('class' => 'btn btn-primary')) }}
</div>
{{ Form:: close() }}

我认为排序打破了结构。