title: Laravel 5.2 - How to access an App Presenter method in EventServiceProvider?
body: <p>I have a guitar lessons site where there is an exercises table. The original developers placed some functions in ExercisePresenter to retrieve other bits of data associated with an exercise, such as its url.</p>
  
  <p>Here is a function in ExercisePresenter that returns url for an exercise:</p>
  
  <pre><code>public function url()
  {
      return '/guitar-lesson-ex/' . $this-&gt;urlName() . '/' . $this-&gt;id;
  }
  </code></pre>
  
  <p>So now I am creating an event on new exercise created so I can use pusher notifications. In the EventServiceProvider I have this:</p>
  
  <pre><code>public function boot(DispatcherContract $events)
  {
      parent::boot($events);
  
      Exercise::created(function ($exercise) {
          // need to update lesson difficulty
          $lesid = $exercise-&gt;lesson_id;
          $les = \App\Lesson::find($lesid);
          $dif = $les-&gt;difficulty();
          DB::table('lessons')
              -&gt;where('id', $lesid)
              -&gt;update(['difficulty' =&gt; $dif]);
  
          // lets trigger NewExerciseEvent to send pusher notifications
          $url = $exercise-&gt;url;
          event(new NewExerciseEvent($message));
      });
  }
  </code></pre>
  
  <p>I thought in above code <code>$url = $exercise-&gt;url;</code> would work since I see <code>$exercise-&gt;url</code> used successfully in exercise views. But it is returning $url as null. Now, there is no url column in the exercise database, so I figure somehow when <code>$exercise-&gt;url;</code> is used in a view, laravel is figuring out that the ExercisePresenter is able to return the url.</p>
  
  <p>I am debugging through PHPStorm, but when I get to <code>$url = $exercise-&gt;url;</code> and step in, I am just taken through various bits of laravel code that looks for a method, etc. I am not savvy enough with laravel to figure out what it is doing here differently than in the view (too bad we can't debug views...), but each time I try this $url is returned as null.</p>
  
  <p>Any idea how to get this to work properly in my EventServiceProvider?</p>
  
  <p>Thanks!</p>