samedi 7 septembre 2019

return eloquent change without update the record on laravel

8 project everything working great so far i have this code

$item = $item_unit->getItem;
$item->item_smallest_unit_cost = $item_unit->item_unit_coast_price;
$item->item_smallest_unit_selling_price = $item_unit->item_unit_selling_price;
return $item->get();

as you can see i need to change the item_smallest_unit_cost and item_smallest_unit_selling_price and then return the item without update the original database but this code return the item with old item item_smallest_unit_selling_price and item_smallest_unit_cost i dont want to do this

$item = $item_unit->getItem;
$item->item_smallest_unit_cost = $item_unit->item_unit_coast_price;
$item->item_smallest_unit_selling_price = $item_unit->item_unit_selling_price;
$item->update // i dont want to do this but i want to return the item new changes
return $item->get();

any help here thanks



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire