mercredi 10 octobre 2018

Laravel: Edit data on the same page it is displayed on

Hello i want to make changes to user data on the same page its been displayed. Basically i want to either select verified or reject, click submit button and the page refreshes with the change. So i have this code:

    <table class="table table-striped">
  <thead>
    <tr>
      <th scope="col">#</th>
      <th scope="col">Name</th>
      <th scope="col">Receipt</th>
      <th scope="col">Status</th>
      <th scope="col"></th>

    </tr>
  </thead>
  <tbody>
    @foreach($users as $user)
    <tr>
      <form method='POST' action="" enctype="multipart/form-data" >
        @csrf
        @method('PUT')

        <th scope="row">  </th>
        <td>  </td>
        <td> 
          <a href="/"></a>
        </td>
        @if( $user->payment_status  != NULL )
            <td>
              PAYMENT VERIFIED  
            </td>
             @else
            <td>
              <div class="form-group">
                <select multiple class="form-control-sm" id="exampleFormControlSelect2" name="nsap_reg" required="" >
                  <option value="verified" >Verified</option>
                  <option value="NULL" >Rejected</option>
                </select>
              </div>
            </td>

          @endif
        <td> 
          <input type="submit" value="SUBMIT" > 
        </td>
      </form>
    </tr>
    @endforeach
  </tbody>
</table>

with this controller:

public function update(Request $request, $id)
    {
        $request->validate([
                'nsap_reg' => 'required',
            ]);

            $payment_status = \App\User::find($id);

            [ 'nsap_reg' => $request->nsap_reg ];

            $payment_status->save();
            return redirect('user-status');
    }

My problem is nothing happens when i click submit. The page just refreshes. Any help will be appreciated.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire