vendredi 11 novembre 2016

Laravel Eloquent Controller Match

I have a table which contains details of an order

  • ID
  • Order No
  • Stock Code
  • Quantity to Deliver

I'm outputting in my view an order and doing a foreach on the items.

This results in a page which allows us to despatch a quantity of our choice.

My question is how do I pass the quantity which may have changed from the order to the controller to update?

For example.

<form>
@foreach($order->items as $item)
<br>
<input name="" value="">
@endforeach

<button type="submit">Send Items</button>
</form>

My controller (just an idea)

public function processDespatch(Request $request, $id)
    {

        $order = Order::where('OH_ORDER_NUMBER',$id)->first();


        foreach($order->items as $item){

            if($item->id = "$request ? ID"){

                PERFORM UPDATE COMMAND IN TABLE

            }

        }
}

You'll see above I've used the phrase "$request ? ID" here I'm struggling how I can link the result?

Hopefully somebody can help



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire