title: PHP Laravel - Best practice to run controller with variable from command
body: <p>I am trying to setup a command in Laravel, that should run every day at 18:30. </p>
  
  <p>I have a function in a controller, I wish to run (is this the correct place to put a function that should only be run from the command line?):</p>
  
  <p><code>ReportController.php</code>:</p>
  
  <pre><code>public function process($reportName)
  {
     return("Function process has run correctly. Report: ".$reportName." ");
  }
  </code></pre>
  
  <p>I have created a command file:</p>
  
  <p><code>ProcessReports.php</code></p>
  
  <pre><code>namespace App\Console\Commands;
  
  use App\Http\Controllers\ReportController;
  use Illuminate\Console\Command;
  
  class ProcessReports extends Command
  {
  
      protected $signature = 'report:process {reportName}';
      protected $description = 'Process reports from FTP server';
  
      public function __construct()
      {
          parent::__construct();
  
      }
      public function handle()
      {
          //
          $ReportController = new ReportController(); 
          $ReportController-&gt;process($reportName);      
      }
  }
  </code></pre>
  
  <p>Furthermore, in my <code>Kernel.php</code> I have registered my command:</p>
  
  <p><code>Kernel.php</code>:</p>
  
  <pre><code> protected $commands = [
              'App\Console\Commands\ProcessReports',
   ];
  
   protected function schedule(Schedule $schedule)
   {
      $schedule-&gt;command('report:process MyReport')
                 -&gt;dailyAt('18:30');                        
   } 
  </code></pre>
  
  <p>I then try to run my command like: <code>$ php artisan report:process MyReport</code>. But this is not possible. It gives me this error:</p>
  
  <blockquote>
    <p>Undefined variable: <strong>reportName</strong></p>
  </blockquote>
  
  <p>Can anyone guide me on how to create commands, which can run my function daily?</p>