title: How to inject repository pattern to event Laravel
body: <p>I use repository patter. If I want use repistory in my controller(for example UserRepository) I simple inject repository in my controller</p>
  
  <pre><code>class SomeController extend BaseController
       public function __contruct(UserRepositoryInterface $user){
            $this-&gt;user = $user;
       }
  </code></pre>
  
  <p>In this example laravel automaticlly inject repository to my controller. But now I would like make some operation on my database from event. So I would like inject UserRepository to my event. How can I do it?</p>
  
  <pre><code> class UserHandlerEvent {
       public function onCreate($event){}
       public function subscribe($events){
           $event-&gt;listen('user.create', 'UserHandlerEvent@onCreate');
   }
  </code></pre>
  
  <p>This is my event, next I regiter it in my EventServiceProvider. It is looks like</p>
  
  <pre><code>class EventServiceProvider extends ServiceProvider
  {
      public function register(){
          $this-&gt;app-&gt;events-&gt;subscribe(new UserEventHandler());
      }
  }
  </code></pre>
  
  <p>What should I do, if I want have to access to UserRepository from my event?</p>