title: How to rollback a transaction in Laravel 5.3?
body: <p>I am trying to create a demo crud using a Laravel 5.3. I wrote a controller's method to handle the update . This method should always starts transaction, and always rollback the changes. So the changes never commit into the database.</p>
  
  <p>Here is how my method looks like</p>
  
  <pre><code>public function update($id, Request $request)
  {
      DB::beginTransaction();
      $this-&gt;affirm($request);
      $biography = Biography::findOrFail($id);
      $data = $request-&gt;all();
      $biography-&gt;update($data);
  
      Session::flash('success_message', 'Biography was updated! However, because this is a demo the records are not persisted to the database.');
      DB::rollBack();
  
      return redirect()-&gt;route('demo.index');
  }
  </code></pre>
  
  <p>Unfortunately, the update still gets committed every time. How can I correctly begin a transaction and then roll back the changes?</p>