Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Danny971's avatar

Why Isn't My Complete Case Working Anymore? It Used to Work!

Hi everyone,

I’m stuck with an issue in my Laravel application. My form submission process used to work perfectly, but now it’s giving me issues

here is my controller for decline and approved cases

HTML and submit button

   </tr>
        {{-- Loop through remaining categories --}}
        @foreach ($requestorders as $key => $ro)
            @if ($key > 0)
                <tr>
                    <td>{{ $ro->category }} @if($ro->substitute) <br> --SUBSTITUTED @endif</td>
                    <!-- <td>{{ $ro->categoryTotal }}</td> -->
                    <td>{{ $ro->requestedItem }}  @if ($ro->substitute_product) <br> (substituted: {{ $ro->substitute_product }}) @endif </td>
                    <td>{{ $ro->amountNeeded }}   @if (isset($ro->substitute_quantity)) <br> (substituted: {{ $ro->substitute_quantity }}) @endif</td>
                    <td><input type="number" name="reev[]" id="reev" data-request-order-id="{{ $ro->id }}" min="0" class="form-control"></td>
                    <td><button type="button" class="btn btn-primary" data-toggle="modal" data-target=".substitute-modal" data-category="{{ $ro ->category }}" data-product="{{ $ro->requestedItem }}" data-request-order-id="{{ $ro->id }}">Substitute</button></td> <!-- this doesnt work  -->
                </tr>
            @endif
        @endforeach
    </tbody>
                                    </table>
                                </div>

                            </div>
                            <button id="submitButton" class="btn btn-primary" data-case-id="{{$pendingcases->id}}"  type="submit" onclick="submitForm()" >Complete Order</button>

                        </div>
                     </div>

JS

                                                     <div class="form-group row">
  <div class="col-lg-8">
    <div class="d-flex align-items-center">
      <h4 class="text-primary mr-2">DECISION:</h4>
      <select class="form-control" id="decisionDropdown" name="decisionDropdown" onchange="toggleReasonDropdown()" >
        <option value="OPTION">Please select</option>
        <option value="APPROVE">APPROVE</option>
        <option value="DECLINE">DECLINE</option>
      </select>
    </div>
  </div>
</div>

when I want to approved it just show as if a modal wants to appear but nothing and decline does nothing it used to work. could it be I used to many submit button

0 likes
8 replies
jlrdw's avatar

Try having a change event for the dropdown.

1 like
jlrdw's avatar
jlrdw
Best Answer
Level 75

@Danny971 As I mentioned in another post, use a combination of dd and your developer tools like console.log, request and response to aid in troubleshooting. That's what the developer tools are for.

I usually figure out what is wrong by using these tools.

1 like
azimidev's avatar

i think you are calling submitForm() inside the click() event handler for the #submitButton, but also calling submitForm() elsewhere, there could be conflicting behavior.

1 like
Danny971's avatar

@jlrdw @azimidev i got this isue

"message": "SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'requestedItem' cannot be null (SQL: insert into received (family_id, requestorder_id, reev, requestedItem) values (398, 2720, 5, ?))",

i need the requestItem

public function fulfillment(Request $request) {

  \Log::info('Fulfillment route hit with data:', $request->all());

  $receivedQuantities = $request->input('receivedQuantities');
  
  
  foreach ($receivedQuantities as $receivedQuantity) {
    $family_id = $receivedQuantity['familyId'];

    $requestOrderId = $receivedQuantity['requestOrderId'];

    $requestedItem = $receivedQuantity['requestedItem'];

    $receivedQty = (int) ($receivedQuantity['receivedQuantity']);

  $received = new received();
    $received->family_id = $family_id;
    $received->requestorder_id = $requestOrderId;
    $received->reev = $receivedQty;
    $received->requestedItem = $requestedItem;
    $received->save();
}

i don't know where in this i have the issue

Please or to participate in this conversation.