title: Laravel Scheduler - how to output chained / series commands?
body: <p>This question is similar to <a href="https://stackoverflow.com/a/29825558/3092596">this one</a> except that:</p>
  
  <ul>
  <li>I need to send the output of the chained (2nd, 3rd or 4th) commands in an <code>emailOutputTo</code> method</li>
  </ul>
  
  <hr>
  
  <p><strong>Single Command Scheduler Code</strong><br>
  This is working fine - both command and the email output:</p>
  
  <pre><code>protected function schedule(Schedule $schedule)
  {
      $schedule   -&gt;command('commandA:myoption')
                  -&gt;emailOutputTo('myemail@gmail.com');
  }
  </code></pre>
  
  <hr>
  
  <p><strong>Chained Command / Call - Using Previous SO Answer</strong><br>
  The aforementioned <a href="https://stackoverflow.com/a/29825558/3092596">accepted answer</a> runs <code>commandB</code> correctly but because it uses <code>-&gt;call()</code> it does not include the output for <code>commandB</code> in the email:</p>
  
  <pre><code>protected function schedule(Schedule $schedule) {
      $schedule   -&gt;command('commandA:myoption')
                  -&gt;then(function() {
                      return $this-&gt;call('commandB:myoption');
                  })
                  -&gt;emailOutputTo('myemail@gmail.com');
  }
  </code></pre>
  
  <p>...<a href="https://laravel.com/docs/5.4/scheduling#task-output" rel="nofollow noreferrer">as noted here</a> it's not possible to email from a Scheduler <code>-&gt;call()</code> method, only when using the <code>-&gt;command()</code> method :  </p>
  
  <blockquote>
    <p>The emailOutputTo, sendOutputTo and appendOutputTo methods are exclusive to the command method and are not supported for call.</p>
  </blockquote>
  
  <p>I tried a modification of the aforementioned <a href="https://stackoverflow.com/a/29825558/3092596">accepted answer</a> to use <code>-&gt;command()</code><br>
  instead of <code>-&gt;call()</code> :</p>
  
  <pre><code>protected function schedule(Schedule $schedule) {
      $schedule   -&gt;command('commandA:myoption')
                  -&gt;then(function() {
                      $this-&gt;command('commandB:myoption');
                              -&gt;emailOutputTo('myemail@gmail.com');
                  })
                  -&gt;emailOutputTo('myemail@gmail.com');
  }
  </code></pre>
  
  <p>...gives the following error:</p>
  
  <blockquote>
    <p>[Symfony\Component\Debug\Exception\FatalThrowableError]<br>
    Type error: Too few arguments to function
    Illuminate\Foundation\Console\Kernel::command(), 1 passed in /app/Console/Kernel.php on line 33 and exactly 2 expected</p>
  </blockquote>
  
  <hr>
  
  <p><strong>Other Attempts at Chained / Series Commands</strong>  </p>
  
  <p>Tried various methods to chain commands <a href="https://github.com/illuminate/console/blob/5.4/Scheduling/Event.php#L581" rel="nofollow noreferrer">using a <code>then</code> function</a> - none seem to work (either running the command or output):</p>
  
  <p><strong><em>Option 1</em></strong> - try to include output into a <em>common</em> email<br>
  Result = <code>commandB</code> not performed, only emails the commandA output:</p>
  
  <pre><code>protected function schedule(Schedule $schedule) {
      $schedule   -&gt;command('commandA:myoption')
                  -&gt;then(function(Schedule $schedule) {
                      return $schedule-&gt;command('commandB:myoption');
                  })
                  -&gt;emailOutputTo('myemail@gmail.com');
  }
  </code></pre>
  
  <p><strong><em>Option 2</em></strong> - try to include output into a <em>separate</em> email<br>
  (by sending separate email outputs in the primary and 2nd commands)</p>
  
  <p>Result = <code>commandB</code> not performed, only emails the commandA output:</p>
  
  <pre><code>protected function schedule(Schedule $schedule) {
      $schedule   -&gt;command('commandA:myoption')
                  -&gt;then(function(Schedule $schedule) {
                      $schedule-&gt;command('commandB:myoption')
                              -&gt;emailOutputTo('myemail@gmail.com');
                  })
                  -&gt;emailOutputTo('myemail@gmail.com');
  }
  </code></pre>
  
  <p><strong><em>Option 3</em></strong> - another variation injecting $schedule - with no success (same result)</p>
  
  <pre><code>protected function schedule(Schedule $schedule) {
      $schedule   -&gt;command('commandA:myoption')
                  -&gt;then(function() use($schedule) {
                      return $schedule-&gt;command('commandB:myoption')
                                  -&gt;emailOutputTo('myemail@gmail.com');
                  })
                  -&gt;emailOutputTo('myemail@gmail.com');
  }
  </code></pre>
  
  <hr>
  
  <p><strong>Questions</strong><br>
  How do you chain commands in the scheduler and send the output from all commands to either </p>
  
  <ul>
  <li>a common email ?</li>
  <li>separate emails (if common isn't possible) ?  </li>
  </ul>
  
  <p>...as an aside, why is everyone so excited by Laravel when the documentation is <em>so pathetically incomplete !!?</em></p>