Laravel包中的验证器



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

Object of class IlluminateValidationFactory 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();
    }

您在此字符串$this->$validator = $validator;

中有错误

需要$this->validator = $validator;

最新更新