laravel包中的验证器

时间:2015-05-02 23:20:52

标签: php laravel-4 laravel-validation

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

1 个答案:

答案 0 :(得分:2)

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

中有错误

需要$this->validator = $validator;