Advertisement
Guest User

Untitled

a guest
Jul 24th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. <?php
  2. namespace App\Aggregators\Object;
  3. use App\Service\ObjectService;
  4. use App;
  5. class RestourantAggregator
  6. {
  7. public function getSertvice():ObjectService
  8. {
  9. return App::make(ObjectService::class);
  10. }
  11. }
  12. <?php
  13. namespace App\Aggregators\Object;
  14. use App\Service\ObjectService;
  15. use App;
  16. class BeautyAggregator
  17. {
  18. public function getSertvice():ObjectService
  19. {
  20. return App::make(ObjectService::class);;
  21. }
  22. }
  23. и использую contextual binding
  24. $this->app->when(BeautyAggregator::class)
  25. ->needs(ObjectService::class)
  26. ->give(function ($app) {
  27. return new BeautyImpl($app->make(TimetableService::class), $app->make(ObjectRepository::class));
  28. });
  29. $this->app->when(RestourantAggregator::class)
  30. ->needs(ObjectService::class)
  31. ->give(function ($app) {
  32. return new RestaurantImpl($app->make(TimetableService::class), $app->make(ObjectRepository::class));
  33. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement