title: How $this->app->singleton() works in laravel?
body: <p>In my laravel project I have following interface, repository and controller.</p>
  <p>This is Interface</p>
  <pre><code>interface TrainingClassTypeInterfaces
  {
      public function updateTrainingClassType($id, $request);
  } 
  </code></pre>
  <p>This is Repository</p>
  <pre><code>use App\Models\Trainings\AppTrainingClassType;
  class TrainingClassTypeEloquent implements TrainingClassTypeInterfaces
      {
          protected $model;
      
          public function __construct(AppTrainingClassType $appTrainingClassType)
          {
              $this-&gt;model = $appTrainingClassType;
          }
      
          public  function updateTrainingClassType($id, $request)
          {
              $response = false;
              $isUpdated = $this-&gt;model::where('training_class_id',$id)-&gt;update([
                  'app_id' =&gt; $request-&gt;app_id
              ]);
              .... 
          }
      
      }
  </code></pre>
  <p>This is controller</p>
  <pre><code>class TrainingClassTypesController extends \TCG\Voyager\Http\Controllers\VoyagerBaseController
  {
      protected  $trainingService;
      public function __construct(TrainingClassTypeEloquent $trainingClassTypeInterfaces) {
          $this-&gt;trainingService = $trainingClassTypeInterfaces;
      }
  
      public function insertOrUpdate()
      {
          ...
          $this-&gt;trainingService-&gt;updateTrainingClassType($id, $request);
          ..
      }
  
  }
  </code></pre>
  <p><strong>Everything working fine till here</strong></p>
  <p>As you can see I am using TrainingClassTypeEloquent's method inside <code>TrainingClassTypesController</code>. But it was returning error something like</p>
  <p><code>Argument 1 passed to ...::__construct() must be an instance of</code></p>
  <p>Basically it was asking me to put instance of Model into <code>TrainingClassTypeEloquent</code> class. Then I did as following</p>
  <pre><code>$TCTypes = new AppTrainingClassType();
  $TCT = new TrainingClassTypeEloquent($TCTypes);
  $TCT-&gt;updateTrainingClassType($id, $request);
  </code></pre>
  <p>which was working fine but I was confused that this approach is not proper, there should be some proper way.</p>
  <p>After googling I found another solution which is singleton binding, and then I tried following in AppServiceProvider</p>
  <pre><code>$this-&gt;app-&gt;singleton(
              \App\Services\Voyager\Eloquent\TrainingClassType\TrainingClassTypeInterfaces::class,
              \App\Services\Voyager\Eloquent\TrainingClassType\TrainingClassTypeEloquent::class
          );
  </code></pre>
  <p>After adding this singleton binding, I notice script was working without providing model instance into <code>TrainingClassTypeEloquent</code> class.</p>
  <p>I would like to know how <code>$this-&gt;app-&gt;singleton()</code> is working, so in this way my concept would be clear about it. If someone knows then kindly guide me about it.</p>
  <p>Thank you so much</p>