使用Laravel 5.4遇到挑战请求名称空间

时间:2017-07-12 12:27:38

标签: namespaces laravel-5.4 laravel-request

我正在尝试引用Laravel中的Requests类,我已尝试使用关键字“ use ”进行了很多修复,但每次我都不断获得Reflection异常 说app \ path \ specified不存在。我很困惑。

这是我的代码:`

<?php

namespace App\Http\Controllers;

//namespace App\Http\Request;

//use Illuminate\Http\Requests;

//use app\Http\Requests\ContactFormRequest;
use App\Message;

use App\Mail\SendMessage;
use Session;

//use App\Requests;


class AboutController extends Controller
{
  public function create()
  {
    return view ('about.contact');
  }
  public function store(App\Requests\SendMessageRequest $request)
  {
$message = $request->message;
Mail::to('myemail')
      ->send(new SendMessage($message, $request->email,$request->name));

请求类

<?php

 namespace App\Http\Requests;

 use Illuminate\Foundation\Http\FormRequest;

 class SendMessageRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
public function authorize()
{
    return false;
}

/**
 * Get the validation rules that apply to the request.
 *
 * @return array
 */
public function rules()
{
    return [
        //
        'name' => 'required',
        'email' => 'required|email',
        "message" => 'required',
    ];
}
}

注释行(//)是我尝试过的 SendMessageRequest是我的Request类的名称。

1 个答案:

答案 0 :(得分:0)

抱歉,我无法评论你的帖子。但是你也可以发送SendMessageRequest类吗?这是Laravel中Request的子类吗?