gpt4 book ai didi

php - 错误 : request class does not exist in laravel 5. 5

转载 作者:行者123 更新时间:2023-12-01 22:11:04 25 4
gpt4 key购买 nike

我已经创建了用于验证的自定义请求类。但它显示请求类不存在。我已经使用 artisan 命令创建了请求类。

php artisan make:request JobDetailRequest

这是我的请求类

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class JobDetailRequest 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 [
'jobtitle' => 'bail|required|max:100',
'jobdescription' => 'required',
'experange' => 'required',
'qualification' => 'required',
'joblocation' => 'required',
];
}

public function messages()
{
return [
'jobtitle.required'=>'Job title field required',
'jobdescription.required'=>'Job description field required',
'experange.required'=>'experience field required',
'qualification.required'=>'Qualification required',
'joblocation.required'=>'job location required'
];
}

这是我的 Controller ,我在其中使用自定义请求进行验证

namespace App\Http\Controllers\admin;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Http\Requests\JobDetailRequest;
use App\job_detail;



class jobDetailController extends Controller
{
//
public function __construct()
{
}

public function index()
{
return view('admin.job_details');
}

public function store(JobDetailRequest $request)
{


$jobTitle=$request->jobtitle;
$jobDesc=$request->jobdescription;
$exp=$request->experange;
$qualf=$request->qualification;
$loc=$request->joblocation;

$jobdetails=new job_detail;
$jobdetails->title=$jobTitle;
$jobdetails->desc=$jobDesc;
$jobdetails->exp=$exp;
$jobdetails->qualification=$qualf;
$jobdetails->location=$loc;
$jobdetails->save();
return back()->with('status','Your Job details saved successfully');

}

我也试过 composer dump-autoload。但它不起作用。

最佳答案

我在 Laravel 5.6 中有类似的错误。原来我在自定义 Http 请求文件中有一个错误(缺少括号)。文件没有加载,而不是显示错误。

一旦我修复了文件中的错误,就加载了类并修复了错误。

我希望这对以后遇到此问题的任何人有所帮助。

关于php - 错误 : request class does not exist in laravel 5. 5,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47879899/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com