title: Truncate a table in Laravel 5
body: <p><strong>Description</strong> : I have a table full of tested data. Sometimes, I want to clear it out for new data. I can perform the truncate in the DBMS App like <strong>MySQL WorkBench</strong>, but I'm trying to achieve it within my application instead.</p>
  
  <hr>
  
  <p><strong>Goal</strong> : to make a button to truncate a table in a database when on click.</p>
  
  <hr>
  
  <p>Here are my steps : </p>
  
  <p><strong>1 - Declare a route</strong></p>
  
  <pre><code>Route::delete('visitor/truncate',array('as'=&gt;'visitor.truncate', 'uses'=&gt;'VisitorController@truncate'));
  </code></pre>
  
  <hr>
  
  <p><strong>2 - Create a <code>truncate</code> function in my <code>VisitorController</code></strong></p>
  
  <pre><code>public function truncate()
  {
  
      $visitors = Visitor::all();
      $visitors -&gt;truncate();
  
      return View::make('visitors.index')
          -&gt;with('success', 'Truncate Done');
  }
  </code></pre>
  
  <hr>
  
  <p><strong>3 - Create a button on my view</strong> </p>
  
  <pre><code> {!! Form::model($visitors, array( 'route' =&gt; array('visitor.truncate'),'method' =&gt; 'DELETE')) !!}
            &lt;button type="submit"  class="btn bgm-red btn-float waves-effect waves-effect waves-button waves-float"&gt;&lt;i class="md md-remove"&gt;&lt;/i&gt;&lt;/button&gt;
        {!! Form::close()!!}
  </code></pre>
  
  <hr>
  
  <p><strong>4 - Test</strong> </p>
  
  <p>When I click on it, it get into my <code>truncate()</code> function in my controller, but I keep getting this error </p>
  
  <blockquote>
    <p>Call to undefined method Illuminate\Database\Eloquent\Collection::truncate()</p>
  </blockquote>
  
  <hr>
  
  <p>Do I need include anything to use <code>truncate()</code> ? </p>
  
  <p>Any hints on that will be much appreciated ! </p>