title: Code Reuse : Common Functions - Laravel
body: <p>I'm in the process of Developing APIs for a System whose front end is Android.  App calls the API with <code>lat</code> and <code>lon</code>.</p>
  
  <p>I am using Laravel for this and have developed some APIs already.  I've also created separate controllers for each and is working correctly. </p>
  
  <p>However 2 (<em>Calculate Distance from Latitude and Longitude and return nearest ones in Ascending order</em>) of the functions are used commonly almost in 3 or 4 Controllers:  <code>BusinessController</code> , <code>OfferController</code>, <code>OutletController</code>.  I thought it would be better to reuse the code passing parameters correspondingly. </p>
  
  <p>Where should I place the common functions and how should they be invoked?  Here is the code for <code>controller.php</code></p>
  
  <pre><code>&lt;?php namespace App\Http\Controllers;
  
  use Illuminate\Foundation\Bus\DispatchesCommands;
  use Illuminate\Routing\Controller as BaseController;
  use Illuminate\Foundation\Validation\ValidatesRequests;
  
  abstract class Controller extends BaseController {
  
      use DispatchesCommands, ValidatesRequests;
  
  }
  </code></pre>
  
  <p>PS: I'm somewhat new to Laravel.</p>