title: Laravel: Check checkbox if true or false, then update database
body: <p>Just started with laravel using phpStorm. Im trying to create a form that take inputs, and a checkbox, then adds it to a database.
  All of the rows in the database get listed in the view index.html. The user should be allowed to activate or deactivate (with the checkbox) the the message that should be listed when browsing the index.html file. Because if a news article is active, and you want to deactivate it, you should be able to just uncheck the checkbox, and it will be deactivated.
  So I am wondering how my function should look like.</p>
  
  <p>Im also unsure how to run the function ActivatedOrDeactivated when the checkbox gets checked or unchecked. </p>
  
  <p>Its my first post, so please tell if something is hard to understand in my description.</p>
  
  <p>My route:</p>
  
  <pre><code>Route::get('admin',
      [
          'uses' =&gt; 'NyhetsController@index',
          'as' =&gt; 'admin.index'
      ]
  );
  
  
  Route::get('admin/create',
      [
          'uses' =&gt; 'NyhetsController@create',
          'as' =&gt; 'admin.create'
      ]
  );
  
  Route::post('admin',
      [
          'uses' =&gt; 'NyhetsController@store',
          'as' =&gt; 'admin.store'
      ]
  );
  
  Route::get('admin/{id}',
      [
          'uses' =&gt; 'NyhetsController@show',
          'as' =&gt; 'admin.show'
      ]
  );
  
  Route::get('admin/{id}/edit',
      [
          'uses' =&gt; 'NyhetsController@edit',
          'as' =&gt; 'admin.edit'
      ]
  );
  
  Route::put('admin/{id}',
      [
          'uses' =&gt; 'NyhetsController@update',
          'as' =&gt; 'admin.update'
      ]
  );
  
  Route::get('admin/{id}/delete',
      [
          'uses' =&gt; 'NyhetsController@delete',
          'as' =&gt; 'admin.delete'
      ]
  );
  
  Route::delete('admin/{id}',
      [
          'uses' =&gt; 'NyhetsController@destroy',
          'as' =&gt; 'admin.destroy'
      ]
  );
  </code></pre>
  
  <p>My Controller that contains the function (just something i wrote in anger):</p>
  
  <pre><code>public function ActivatedOrDeactivated($id){
  $news = News::findOrFail($id);
  $input = Input::get('active');
  
  if($input == true)
  {
      $news-&gt;active = 'false';
      $news-&gt;update($input);
  }
  else{
      $news-&gt;active = 'true';
      $news-&gt;update($input);
  }
  }
  </code></pre>
  
  <p>My index file that contains the form:</p>
  
  <pre><code>&lt;h1&gt;Alle postene i databasen&lt;/h1&gt;
  
  &lt;p&gt;{{ link_to_route('admin.create', 'Legg til ny nyhet') }}&lt;/p&gt;
  
  
  @if($news-&gt;count())
      &lt;table class="table table-striped table-boarded"&gt;
          &lt;thead&gt;
              &lt;tr&gt;ID&lt;/tr&gt;
              &lt;tr&gt;Title&lt;/tr&gt;
              &lt;tr&gt;Author&lt;/tr&gt;
              &lt;tr&gt;Message&lt;/tr&gt;
              &lt;tr&gt;Active&lt;/tr&gt;
              &lt;tr&gt;Picture path&lt;/tr&gt;
              &lt;tr&gt;Activate/Deactivate&lt;/tr&gt;
          &lt;/thead&gt;
  
          &lt;tbody&gt;
              @foreach($news as $n)
                  &lt;tr&gt;
                      &lt;td&gt;{{ $n-&gt;id }}&lt;/td&gt;
                      &lt;td&gt;{{ $n-&gt;title }}&lt;/td&gt;
                      &lt;td&gt;{{ $n-&gt;author }}&lt;/td&gt;
                      &lt;td&gt;{{ $n-&gt;message }}&lt;/td&gt;
                      &lt;td&gt;{{ $n-&gt;active }}&lt;/td&gt;
                      &lt;td&gt;{{ $n-&gt;picture_path }}&lt;/td&gt;
                      &lt;td&gt;{{ Form::checkbox('active') }}&lt;/td&gt;
                      &lt;td&gt;{{ link_to_route('admin.destroy', 'Delete', array($n-&gt;id)) }}&lt;/td&gt;
  
                  &lt;/tr&gt;
              @endforeach
          &lt;/tbody&gt;
      &lt;/table&gt;
  </code></pre>