致命错误:发送表单时未找到类“App \Http\Controllers\Input” [英] Fatal error: Class 'App\Http\Controllers\Input' not found when sending a form
本文介绍了致命错误:发送表单时未找到类“App \Http\Controllers\Input”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当您点击提交时,会抛出上述错误:
致命错误:Class'App \Http\Controllers\Input'未找到
不知道为什么我没有,也不知道我需要一个输入控制器,或者我会放入它。
以下是控制器的内容:
< php
命名空间App \Http\Controllers;
使用Illuminate \Http\Request;
使用App \Http\Requests;
class contact extend Controller
{
//此函数将显示视图
public function showForm()
{
return view( 'pages.contact');
$ b $公共函数handleFormPost()
{
$ input = Input :: only('name','email','msg');
$ b $ validator = Validator :: make($ input,
array(
'name'=>'required',
'email'=>' required'email',
'msg'=>'required',
)
); ($ errors),$ validator->失败())
返回Redirect :: to('contact') - > >消息());
} else {//验证未失败,它已通过
//发送带有contactemail视图的电子邮件,用户输入
Mail ::从('idocompscihw@gmail.com','您的姓名');
$ b发送('contactemail',$ input,function($ message)
{
$ message-> $ b $ message->到('idocompscihw@gmail.com');
});
//在发送消息以提供用户反馈后,指定要去的路线
return Redirect :: to('thanks');
}
}
}
下面是(基于bootstrap):
< div class =container>
< h1>基本联络表单< / h1>
@if(Session :: has('errors'))
< div class =alert alert-warning>
@foreach(Session :: get('errors') - > all()as $ error_message)
< p> {{$ error_message}}< / p>
@endforeach
< / div>
@endif
< div class =row>
< div class =col-xs-6 col-md-6 form-group>
< input type =hiddenname =_ tokenvalue ={{csrf_token()}}>
< input class =form-controlid =namename =nameplaceholder =Nametype =textautofocus =>
< / div>
< div class =col-xs-6 col-md-6 form-group>
< input class =form-controlid =emailname =emailplaceholder =Emailtype =text>
< / div>
< / div>
< br>
< div class =row>
< div class =col-xs-12 col-md-12 form-group>
< button class =btn btn-primary pull-righttype =submit>提交< / button>
< / div>
< / div>
< / form>
< / div>
解决方案
在您的contact.php中使用此控制器 -
使用Illuminate\Support\Facades\Input;
您的错误将得到修复。谢谢。
I'm trying to send an email filled with a form from a Laravel app.
When you hit submit it throws the above error:
Fatal error: Class 'App\Http\Controllers\Input' not found
Not sure why as I don't have, nor knew I needed to have an Input controller, or what I would put in it.
Below is the content of the 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('contact')->with('errors', $validator->messages());
} else { // the validation has not failed, it has passed
// Send the email with the contactemail view, the user input
Mail::send('contactemail', $input, function($message)
{
$message->from('idocompscihw@gmail.com', 'Your Name');
$message->to('idocompscihw@gmail.com');
});
// Specify a route to go to after the message is sent to provide the user feedback
return Redirect::to('thanks');
}
}
}
Below is the view of the forum (based on bootstrap):
<div class="container">
<h1>A basic contact form</h1>
<form id="contact" method="post" class="form" role="form">
@if(Session::has('errors'))
<div class="alert alert-warning">
@foreach(Session::get('errors')->all() as $error_message)
<p>{{ $error_message }}</p>
@endforeach
</div>
@endif
<div class="row">
<div class="col-xs-6 col-md-6 form-group">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<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>
解决方案
Used this in your contact.php Controllers-
use Illuminate\Support\Facades\Input;
your error will get fixed. Thanks.
这篇关于致命错误:发送表单时未找到类“App \Http\Controllers\Input”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文