title: Laravel BD::rollBack Don't work in my code
body: <p>I made the code below in order to validate a transaction in which the balance and history would be saved in the database or none of them. However, when I run the code and check the database I see that the balance is still being inserted into the bank instead of being canceled. What could be the mistake?</p>
  
  <p>Below is the method code of my balance model responsible for the operation</p>
  
  <pre><code>public function deposit(float $value) : Array {
  
          DB::beginTransaction();
  
          $totalBefore = null;
          // $totalBefore = $this-&gt;amount ? $this-&gt;amount : 0;
          $this-&gt;amount += number_format($value, 2, ".", '');
          $deposit = $this-&gt;save();
  
          $historic = auth()-&gt;user()-&gt;historics()-&gt;create([
              'type'          =&gt; 'I', 
              'amount'        =&gt; $value, 
              'total_before'  =&gt; $totalBefore, 
              'total_after'   =&gt; $this-&gt;amount, 
              'date'          =&gt; date('Ymd'),
          ]);
  
          if ($deposit &amp;&amp; $historic) {
              DB::commit();
  
              return [
                  'success' =&gt; true,
                  'message' =&gt; 'Sucesso ao recarregar!'
              ];
          }
  
          else {
              DB::rollBack();
  
              return [
                  'success' =&gt; false,
                  'message' =&gt; 'Falha ao recarregar!'
              ];
          }     
      } 
  </code></pre>