dongzhan8620 2016-05-13 06:45
浏览 211

致命错误:发送表单时找不到类'App \ Http \ Controllers \ 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>
  • 写回答

4条回答 默认 最新

  • dongyin4202 2016-05-13 06:47
    关注

    you not use input try this :

    use Input;
    

    Put it after the namespace declaration like this

    <?php 
    
    namespace App\Http\Controllers; 
    use Input;
    ...
    
    ?>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序