title: Laravel transaction
body: <p>In regarding of Transaction, I have seen two way of doing this and what is the difference of them two and the benefit?</p>
  
  <p>These code in the repo.</p>
  
  <p>Example 1 common approach</p>
  
  <pre><code>DB::transaction(function () {
  
  });
  </code></pre>
  
  <p>What the purpose of this example?</p>
  
  <pre><code>public function createCustomer(Request $request, $id)
      {   
          $self = $this;
  
          return $this-&gt;model-&gt;getConnection()-&gt;transaction(function () use ($self, $request, $id) {
  
          });
  }
  </code></pre>