title: Call to undefined function App\Http\Controllers\ [ function name ]
body: <p>In my controller, I create a function <code>getFactorial</code></p>
  
  <pre><code>public static function getFactorial($num)
  {
      $fact = 1;
      for($i = 1; $i &lt;= $num ;$i++)
          $fact = $fact * $i;
      return $fact;
  }
  </code></pre>
  
  <p>Then, I use it like this </p>
  
  <pre><code>public function codingPuzzleProcess()
  {
  
      $word     = strtoupper(Input::get('word'));
      $length   = strlen($word);
      $max_value = ($length * 26);
      $characters = str_split($word);
  
      $num = 1 ;
      $index = 1;
  
      sort($characters);
  
      foreach ( $characters as $character) {
          $num += getFactorial($index) * $index;
          $index ++;
      }
  
      return Redirect::to('/coding-puzzle')
          -&gt;with('word', $word )
          -&gt;with('num', $num )
          -&gt;with('success','Submit successfully!');
  
  }
  </code></pre>
  
  <p>For some reason, I keep getting this error </p>
  
  <p><code>Call to undefined function App\Http\Controllers\getFactorial()</code></p>
  
  <p>Can someone please teach me how to fix this error ? </p>
  
  <p>Much appreciated in advance. </p>
  
  <hr>
  
  <p><strong>CodeController.php</strong></p>
  
  <pre><code>&lt;?php
  
  namespace App\Http\Controllers;
  use View, Input, Redirect;
  
  class CodeController extends Controller {
  
  
      public function codingPuzzle()
      {
          return View::make('codes.puzzle');
      }
  
      public static function getFactorial($num)
      {
          $fact = 1;
          for($i = 1; $i &lt;= $num ;$i++)
              $fact = $fact * $i;
          return $fact;
      }
  
  
      public function codingPuzzleProcess()
      {
  
          $word     = strtoupper(Input::get('word'));
          $length   = strlen($word);
          $max_value = ($length * 26);
          $characters = str_split($word);
  
          $num = 1 ;
          $index = 1;
  
          sort($characters);
  
          foreach ( $characters as $character) {
              $num += getFactorial($index) * $index;
              $index ++;
          }
  
          return Redirect::to('/coding-puzzle')
              -&gt;with('word', $word )
              -&gt;with('num', $num )
              -&gt;with('success','Submit successfully!');
  
      }
  
  
  }
  </code></pre>