mercredi 27 avril 2016

Access parent class methods from within child class constructor

I am using Laravel 5.3. In my form request which extends the request class I am trying to access method from the parent class but it is throwing an error and I can't seem to see why. My form request constructor looks like the following. Am I missing something here?

The call works when I put it in other methods, just not from the constructor where it ideally needs to be.

Accessing the parent below triggers "Fatal error: Call to a member function get() on null in vendor\laravel\framework\src\Illuminate\Http\Request.php:601"

    protected $test= [];

    public function __construct(myRepositoryInterface $myRepository) {

        $this->myRepository= $myRepository;
        if( parent::has('someName') ){
           $this->test= $myRepository->someMethod(parent::input('someName'));
       }
   }



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire