【发布时间】:2023-03-27 15:42:01
【问题描述】:
这是关于什么的?
我正在使用 Laravel 5.2 并通过运行以下命令来更新作曲家
composer require felixkiss/uniquewith-validator:2.*
然后将以下内容添加到 config/app.php 中的 providers 数组中:
'providers' => array(
// ...
'Felixkiss\UniqueWithValidator\UniqueWithValidatorServiceProvider',
),
我这样做是因为我正在尝试实现多列唯一验证。我的意思是复合键验证。
I am following the instructions as mentioned here
有什么问题?
当 Laravel 运行以下行时。
public function store(Request $request)
{
$v = \Validator::make($request->all(), [
'SubCategory' => 'required|max:25|min:5|unique_with:tblsubcategory,CategoryID',
'CategoryID' => 'required',
]);
if ($v->fails()) {
return \Redirect::back()
->withErrors($v)
->withInput();
}
return Redirect('/SubCategories-List/'.$request->input('CategoryID'));
}
我收到此错误。
UniqueWithValidatorServiceProvider.php 第 27 行中的 FatalErrorException:调用未定义的方法 Illuminate\Support\Facades\Validator::resolver()
重要
这在 Laravel 5.1 中运行良好
【问题讨论】:
-
去掉
\Validator的反斜杠 -
如果我这样做,我会收到错误 Class
App\Http\Controllers\Skills\Validatornot found
标签: php laravel-5 laravel-5.1 laravel-5.2