I'm trying to use the Validator inside my Laravel package. From the service provider Im sending the validator as a constructor parameter to the Exam class but I'm getting this error
Object of class Illuminate\Validation\Factory could not be converted to string
Below is my service provider register function:
public function register()
{
$this->app['exam'] = $this->app->share(function($app)
{
return new Exam($this->app['session.store'],$this->app['validator']);
});
}
and the Exam constructor where the error is generating from:
public function __construct(SessionStore $session, Validator $validator)
{
$this->session = $session;
$this->container = 'Testum_Exam';
$this->$validator = $validator;
$this->initializeExam();
}
You have an error in this string $this->$validator = $validator;
Need $this->validator = $validator;