1

我正在尝试在我的 Laravel 包中使用验证器。从服务提供商我将验证器作为构造函数参数发送到考试类,但我收到此错误

Object of class Illuminate\Validation\Factory could not be converted to string

以下是我的服务提供商注册功能:

public function register()
    {
        $this->app['exam'] = $this->app->share(function($app)
        {
            return new Exam($this->app['session.store'],$this->app['validator']);
        });
    }

以及产生错误的考试构造函数:

public function __construct(SessionStore $session, Validator $validator) 
    {
        $this->session = $session;
        $this->container = 'Testum_Exam';
        $this->$validator = $validator;
        $this->initializeExam();
    }
4

1 回答 1

2

您在此字符串中有错误$this->$validator = $validator;

需要 $this->validator = $validator;

于 2015-05-02T23:27:35.683 回答