Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using a constructor in the Presenter Class #18

Open
warksit opened this issue Aug 11, 2014 · 2 comments
Open

Using a constructor in the Presenter Class #18

warksit opened this issue Aug 11, 2014 · 2 comments

Comments

@warksit
Copy link

warksit commented Aug 11, 2014

I have an Owner Model and an OwnerPresenter class. 'Standard' functionality os working fine. I am now trying to do something in a presenter part of which I will use in other presenters (but not all) so would like to utilise DI using a constructor in my Presenter Class. I get the following error:

Argument 1 passed to Owners\OwnerPresenter::__construct() must be an instance of Utilities\AddressBuilder, instance of Owners\Owner given, called in /home/vagrant/project1/vendor/laracasts/presenter/src/Laracasts/Presenter/PresentableTrait.php on line 29 and defined (View: /home/vagrant/project1/app/views/search.blade.php)

I have tried adding parent::_construct and parent::_construct($this->entity) but I am getting the same error.

I can see that there is a conflict with the constructors but struggling to work out how to solve it

@marcusmoore
Copy link

I'm in the same boat. Did you end up working something out?

@cmorbitzer
Copy link

For future reference, dependencies can be resolved using the resolve helper. https://laravel.com/docs/5.6/container#resolving

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants