我正在尝试在我的 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();
}