I'm running through this tutorial http://laravelblog.com/how-to-create-a-basic-contact-form-validate-input-and-send-mail
Not sure what I am doing that is throwing this error as I followed his directions almost exactly. My controller name is different but I've accounted for that. Here is my controller
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
class contact extends Controller
{
// This function will show the view
public function showForm()
{
return view('pages.contact');
}
public function handleFormPost()
{
$input = Input::only('name', 'email', 'msg');
$validator = Validator::make($input,
array(
'name' => 'required',
'email' => 'required|email',
'msg' => 'required',
)
);
if ($validator->fails())
{
return Redirect::to('contactform')->with('errors', $validator->messages);
}
}
}
Here is my routes.php
<?php
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
Route::get('/', function () {
return view('pages.home');
});
Route::get('request', 'controller@request');
//Route::get('contact', 'controller@contact');
Route::get('contact', 'contact@showform');
Route::post('contact', 'contact@handleFormPost');
Here is my contact.blade.php
@extends("layout")
@section("content")
<h1>Contact</h1>
<div class="text-center">
<img src="http://i.imgur.com/hSuGkPM.png" alt="">
<p><br>Join our discord server to get an immediate response about your project</p><br>
</div>
<!--
<form class="form-horizontal" role="form">
<div class="form-group">
<label class="control-label col-sm-2" for="email">Email:</label>
<div class="col-sm-10">
<input type="email" class="form-control" id="email" placeholder="Enter email">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="msg">Message:</label>
<div class="col-sm-10">
<textarea class="form-control" rows="5" id="message" placeholder="Message"></textarea>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-default">Submit</button>
</div>
</div>
</form>
-->
<div class="container">
<h1>A basic contact form</h1>
<form id="contact" method="post" class="form" role="form">
<div class="row">
<div class="col-xs-6 col-md-6 form-group">
<input class="form-control" id="name" name="name" placeholder="Name" type="text"autofocus="">
</div>
<div class="col-xs-6 col-md-6 form-group">
<input class="form-control" id="email" name="email" placeholder="Email" type="text">
</div>
</div>
<textarea class="form-control" id="message" name="msg" placeholder="Message" rows="5"></textarea>
<br>
<div class="row">
<div class="col-xs-12 col-md-12 form-group">
<button class="btn btn-primary pull-right" type="submit">Submit</button>
</div>
</div>
</form>
</div>
@stop
What can I do to fix this and get moving again?
EDIT: Adding in {{ csrf_field() }} seems to get around the first error but doing so creates a new error "Fatal error: Class 'App\Http\Controllers\Input' not found." I am not familiar with csrf_field, so I did not know I needed this controller or what to put in it