【问题标题】:Call to undefined method Illuminate\Support\Facades\Validator::resolver()调用未定义的方法 Illuminate\Support\Facades\Validator::resolver()
【发布时间】: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\Validator not found

标签: php laravel-5 laravel-5.1 laravel-5.2


【解决方案1】:

遇到完全相同的问题,尽管当我运行 php artisan 命令时出现以下错误 Class validator does not exist

试图弄清楚现在发生了什么

-- 已修复(针对我的问题)--

已将您的作曲家 json 更新到此版本...

“felixkiss/uniquewith-validator”:“2.0.3”

并删除 Whoops,因为这似乎捕获了升级文档确实说可能导致问题的 HttpResponseException

这解决了我的问题。

【讨论】:

    猜你喜欢
    • 2017-08-28
    • 2019-10-15
    • 2020-01-24
    • 2019-03-04
    • 2023-03-24
    • 2019-05-14
    • 2021-10-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多