如何使用自定义请求(make:request)?(laravel)方法App\Http\Requests\Custom::doesExistI不存在

如何使用自定义请求(make:request)?(laravel)方法App\Http\Requests\Custom::doesExistI不存在,laravel,laravel-5.7,laravel-request,Laravel,Laravel 5.7,Laravel Request,我创建了一个自定义请求来进行自己的验证。我跟着这些 我创建了ProfileRequest 在我的个人资料请求中 它返回如下所示的错误: Class App\Http\Controllers\ProfileRequest does not exist 先生们,我需要你们的帮助。有人知道如何使用自定义请求吗?您需要在控制器中导入App\Http\Requests\ProfileRequest 类似:使用App\Http\Requests\ProfileRequest 然后尝试:composer d

我创建了一个自定义请求来进行自己的验证。我跟着这些

我创建了ProfileRequest

在我的个人资料请求中

它返回如下所示的错误:

Class App\Http\Controllers\ProfileRequest does not exist
先生们,我需要你们的帮助。有人知道如何使用自定义请求吗?

您需要在控制器中导入App\Http\Requests\ProfileRequest

类似:使用App\Http\Requests\ProfileRequest

然后尝试:composer dumpautoload,php artisan cache:clear

您需要在控制器中导入App\Http\Requests\ProfileRequest

类似:使用App\Http\Requests\ProfileRequest

然后尝试:composer dumpautoload,php artisan cache:clear

您已经导入了use-illumb\Http\Request

您必须在控制器上导入ProfileRequest而不是Request

use App\Http\Requests\ProfileRequest;


 $validated = $request->validated();
        if ($validated) {
             // ...
         }
仅此而已:

use App\Http\Requests\ProfileRequest;
您已导入use\Http\Request

您必须在控制器上导入ProfileRequest而不是Request

use App\Http\Requests\ProfileRequest;


 $validated = $request->validated();
        if ($validated) {
             // ...
         }
仅此而已:

use App\Http\Requests\ProfileRequest;
试试这个, 首先,您必须在控制器中导入请求

use App\Http\Requests\ProfileRequest;


 $validated = $request->validated();
        if ($validated) {
             // ...
         }
希望这有帮助:

试试这个, 首先,您必须在控制器中导入请求

use App\Http\Requests\ProfileRequest;


 $validated = $request->validated();
        if ($validated) {
             // ...
         }

希望这有帮助:

在ProfileRequest.php中 改变

然后就

php artisan config:cache 
composer dumpautoload

在ProfileRequest.php中 改变

然后就

php artisan config:cache 
composer dumpautoload
在ProfileRequest中,将FormRequest更改为extends Request。然后添加use\Http\Request;在班级之上。代码应该如下所示

<?php

namespace App\Http\Requests;

use Illuminate\Http\Request;

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

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'name' => 'required|min:10',
            'age' => 'required|numeric'
        ]; 
    }
}
然后放入App\Http\Requests\ProfileRequest;在控制器中。

在ProfileRequest中,将FormRequest更改为extends Request。然后添加use\Http\Request;在班级之上。代码应该如下所示

<?php

namespace App\Http\Requests;

use Illuminate\Http\Request;

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

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'name' => 'required|min:10',
            'age' => 'required|numeric'
        ]; 
    }
}
然后放入App\Http\Requests\ProfileRequest;在控制器中。创建配置文件请求

php artisan make:请求配置文件/ProfileRequest 内部配置文件请求

创建配置文件请求

php artisan make:请求配置文件/ProfileRequest 内部配置文件请求


Sir它返回一个错误类App\Http\Controllers\ProfileRequest不存在。bdw我发出的ProfileRequest是一个存储在App/Http/Requests/I trued Sir中的请求,但返回一个类似以下方法的错误:App\Http\Requests\ProfileRequest::doesExistI不存在。先生,你能帮我查一下我个人资料的密码吗。感谢您的回复,否则返回一个错误类App\Http\Controllers\ProfileRequest不存在。bdw我发出的ProfileRequest是一个存储在App/Http/Requests/I trued Sir中的请求,但返回一个类似以下方法的错误:App\Http\Requests\ProfileRequest::doesExistI不存在。先生,你能帮我查一下我个人资料的密码吗。感谢您的回复,否则它将返回一个错误方法App\Http\Requests\ProfileRequest::doesExistI不存在。您能检查一下我的ProfileRequest的代码吗?先生,我想问题出在那里,我不确定您能在这里添加您的完整ProfileController类和ProfileRequest类吗?这是我的完整ProfileController SirSir。它返回一个错误方法App\Http\Requests\ProfileRequest::doesExistI不存在。你能检查一下我的ProfileRequest的代码吗先生,我想问题就在那里,我不确定你能不能在这里添加你的完整ProfileController类和ProfileRequest类?这是我的完整ProfileController SirSir它返回一个错误方法App\Http\Requests\ProfileRequest::doesExistI不存在。。我认为问题在于ProfileRequestCodes SirI在文章中观察到了Sir Good,定制请求扩展了一个请求。先生,你能帮我查一下吗。谢谢你的回复,我用FormRequest实现了它,当时我不知道它是用request实现的,没问题,谢谢你的指导。您可以使用composer dump autoload进行检查。我尝试了composer dump autoload,但仍然返回此错误方法App\Http\Requests\ProfileRequest::doesExistI不存在。我真的不知道这有什么问题。尝试过php artisan cache:clear,但仍然返回相同的错误:Sir它返回一个错误方法App\Http\Requests\ProfileRequest::doesExistI不存在。。我认为问题在于ProfileRequestCodes SirI在文章中观察到了Sir Good,定制请求扩展了一个请求。先生,你能帮我查一下吗。谢谢你的回复,我用FormRequest实现了它,当时我不知道它是用request实现的,没问题,谢谢你的指导。您可以使用composer dump autoload进行检查。我尝试了composer dump autoload,但仍然返回此错误方法App\Http\Requests\ProfileRequest::doesExistI不存在。我真的不知道这有什么问题。尝试过php artisan缓存:clear,但仍然返回相同的错误:@princekumardwedi Sir它返回一个错误类App\Http\Controllers\ProfileRequest不存在。bdw我发出的ProfileRequest是一个存储在App/Http/Requests/Sorry中的请求,它是我使用App\Http\Requests\ProfileRequest的错误;试试这个
是正确的。它返回错误sir Class App\Http\ProfileRequest没有exist@PrinceKumarDwivediSir它返回一个错误类App\Http\Controllers\ProfileRequest不存在。bdw我发出的ProfileRequest是一个存储在App/Http/Requests/Sorry中的请求,它是我使用App\Http\Requests\ProfileRequest的错误;试试看,这是正确的。它返回错误sir Class App\Http\ProfileRequest不存在sir它返回的类“Illumb\Http\FormRequest”未找到您是否使用了“use Illumb\Http\Request;”“使用\Http\FormRequest;”在您的控制器中?我已更改,但另一个错误返回类App\Http\Controllers\ProfileRequest不存在将其添加到控制器的命名空间App\Http\Controllers;的顶部是的,先生,我有名称空间App\Http\Controllers;在我的controllerSir中,它返回类'illumb\Http\FormRequest'未找到您是否使用了'use illumb\Http\Request;'“使用\Http\FormRequest;”在您的控制器中?我已更改,但另一个错误返回类App\Http\Controllers\ProfileRequest不存在将其添加到控制器的命名空间App\Http\Controllers;的顶部是的,先生,我有名称空间App\Http\Controllers;在我的controllerI中,我这样做了,但返回了一个错误,Sir类“App\Http\Requests\Request”未找到,还添加了use-illumb\Http\Request;在ProfileRequestI的顶部,我执行了此操作,但返回了一个错误Sir类“App\Http\Requests\Request”未找到还添加了use-illumb\Http\Request;在ProfileRequest之上