我正在尝试使用Laravel包中的 Validator 。从服务提供商Im发送验证器作为构造函数参数到Exam类,但我收到此错误
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']);
});
}
以及从中生成错误的Exam构造函数:
public function __construct(SessionStore $session, Validator $validator)
{
$this->session = $session;
$this->container = 'Testum_Exam';
$this->$validator = $validator;
$this->initializeExam();
}
答案 0 :(得分:2)
此字符串$this->$validator = $validator;
需要$this->validator = $validator;