使用 Entrust 时如何修复 Laravel BadMethodCallException

How to fix Laravel BadMethodCallException when using Entrust

总是得到

  [BadMethodCallException]
  This cache store does not support tagging.

每当我尝试 运行 包含保存功能的数据库命令时,它都会产生此错误,我认为是因为委托。

在 RegisterController 上它显示与

相同的错误
  [BadMethodCallException]
  This cache store does not support tagging.

但它仍然注册用户。都一样,但代码的任何其他部分都停止了。我该如何解决这个错误。

<?php

namespace App\Http\Controllers\Auth;

use App\User;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Validator;
use Illuminate\Foundation\Auth\RegistersUsers;

class RegisterController extends Controller
{
    /*
    |--------------------------------------------------------------------------
    | Register Controller
    |--------------------------------------------------------------------------
    |
    | This controller handles the registration of new users as well as their
    | validation and creation. By default this controller uses a trait to
    | provide this functionality without requiring any additional code.
    |
    */

    use RegistersUsers;

    /**
     * Where to redirect users after registration.
     *
     * @var string
     */
    protected $redirectTo = '/home';

    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('guest');
    }

    /**
     * Get a validator for an incoming registration request.
     *
     * @param  array  $data
     * @return \Illuminate\Contracts\Validation\Validator
     */
    protected function validator(array $data)
    {
        return Validator::make($data, [
            'name' => 'required|max:255',
            'email' => 'required|email|max:255|unique:users',
            'password' => 'required|min:6|confirmed',
        ]);
    }

    /**
     * Create a new user instance after a valid registration.
     *
     * @param  array  $data
     * @return User
     */
    protected function create(array $data)
    {
        return User::create([
            'name' => $data['name'],
            'email' => $data['email'],
            'password' => bcrypt($data['password']),
        ]);
    }
}

注册控制器代码

在您的 .env 文件中设置 CACHE_DRIVER=array

Source

为了更正这个问题,我完全退出了 Entrust Package 并创建了一个新的

ROLE PERMISSION MODEL AND TABLE WITH THE SAME SCHEMA

as委托运行数据库迁移并使用tinker填充数据。

NEXT I EDITED THE MIDDLEWARE OF ENTRUST TO SEE MY ROLE, PERMISSION AS STRINGS

创建模型后。只需 Zizaco\Entrust\Middleware\EntrustRole 并删除爆炸功能。对于其他两个中间件