20 lines
430 B
PHP
20 lines
430 B
PHP
<?php
|
|
|
|
namespace App\Traits\Purchase;
|
|
|
|
use App\Models\PurchaseItem;
|
|
|
|
trait WithDeleteItem
|
|
{
|
|
public function deleteItem(PurchaseItem $item): void
|
|
{
|
|
$this->purchaseItems = $this->purchaseItems->reject(fn ($i) => $i->id === $item->id);
|
|
|
|
$item->delete();
|
|
|
|
$this->form->total = formatCurrencyNumber($this->purchaseItems->sum('total_price'), '');
|
|
|
|
$this->toast('Item berhasil dihapus.');
|
|
}
|
|
}
|