laravel 包中的验证器
Validator in a laravel package
我正在尝试在我的 Laravel 包中使用 Validator。从服务提供商我将验证器作为构造函数参数发送给考试 class 但我收到此错误
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();
}
你在这个字符串中有错误$this->$validator = $validator;
需要$this->validator = $validator;
我正在尝试在我的 Laravel 包中使用 Validator。从服务提供商我将验证器作为构造函数参数发送给考试 class 但我收到此错误
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();
}
你在这个字符串中有错误$this->$validator = $validator;
需要$this->validator = $validator;