title: Update status in database using checkbox - Laravel
body: <p>The project can have different statuses. With the checkbox, I am trying to switch the status of the project from requested (1) to accepted (2). If the checkbox is unchecked the status is 1, checked it's 2.</p>
  
  <p>When I check the checkbox I got a 419 but this is normally related to the token but I added a @csfr field. Why is the status not changed in the database?
  Thanks for any help.</p>
  
  <h3>index.blade.php (summary of all the projects)</h3>
  
  <pre><code> @foreach ($projects as $project)
  
          &lt;tbody&gt;
              &lt;tr&gt;
                  &lt;form action="/projects/plan" method="post" id="statusForm"&gt;
                   @csrf
                      &lt;input name="id" type="hidden" value="{{$project-&gt;id}}"&gt;
                      &lt;td&gt;
                          &lt;input type="hidden" value="{{$project-&gt;status}}" name="status"&gt; 
                          &lt;input {{isset($project['status']) &amp;&amp; $project['status'] == '2' ? 'checked' : ''}} 
                                  value="{{$project-&gt;status}}" type="checkbox" name="status" 
                                  onchange="document.getElementById('statusForm').submit()"
                          &gt;
                      &lt;/td&gt;
                  &lt;/form&gt;
                  &lt;td&gt;{{$project-&gt;applicant_name}}&lt;/td&gt;
                  &lt;td&gt;{{$project-&gt;project_name}}&lt;/td&gt;
                  &lt;td&gt;&lt;a href="/events/{{$projects-&gt;id}}/edit" class="btn btn-secondary btn-sm" role="button"&gt;Project Details&lt;/a&gt;&lt;/td&gt;
              &lt;/tr&gt;
          &lt;/tbody&gt;
  
      @endforeach
  </code></pre>
  
  <h3>Project.php (functions to update status)</h3>
  
  <pre><code>    const STATUS_requested  = 1;
      const STATUS_ACCEPTED   = 2;
  
      public function updateStatus( $status )
      {
          $this-&gt;update([
              'status'    =&gt; $status
          ]);
          $this-&gt;refresh();
          return $this;
      }
  
      public function projectAccept()   { 
  
          return $this-&gt;updateStatus( self::STATUS_ACCEPTED );   
  
      }
  </code></pre>
  
  <h3>ProjectsController.php (dd('hello') is not printed it seems like data is not sent to this resource)</h3>
  
  <pre><code>    public function plan(Request $request)
      {
          dd('hello');
          Event::find($request-&gt;id)-&gt;projectAccept();
          return Project::STATUS_ACCEPTED;
      }
  </code></pre>
  
  <h3>web.php</h3>
  
  <pre><code>// Update status project
  Route::post('/projects/plan',                 'ProjectsController@plan');
  </code></pre>