mardi 31 mars 2020

How to use Model in function parameter to reduce code in laravel?

This is how i am trying to update record in my laravel function which doesn't work

  public function completePacking(SaleOrder $saleOrder)
  {
    $saleOrder->update(['status' => 'Draft']);
  }

it is working

  public function completePacking($id)
  {
     $saleOrder = SaleOrder::findOrFail($id);
     $saleOrder->status = 'Dispatched';
     $saleOrder->save();
}

i want to use first method because it is less code but that is not working



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2WYqh70
via IFTTT

Aucun commentaire:

Enregistrer un commentaire