41 lines
905 B
PHP
41 lines
905 B
PHP
<?php
|
|
|
|
namespace App\Livewire\Studio\Manage\Purchase;
|
|
|
|
use App\Models\Purchase;
|
|
use App\Traits\Purchase\WithUpdateStock;
|
|
use App\Traits\WithCloseModal;
|
|
use App\Traits\WithConfirmation;
|
|
use App\Traits\WithToast;
|
|
use Flux\Flux;
|
|
use Livewire\Attributes\Title;
|
|
use Livewire\Component;
|
|
|
|
#[Title('Belanja')]
|
|
class Index extends Component
|
|
{
|
|
use WithCloseModal, WithConfirmation, WithToast, WithUpdateStock;
|
|
|
|
public function delete(Purchase $purchase)
|
|
{
|
|
foreach ($purchase->items as $item) {
|
|
$this->decreaseOutletStock($purchase->outlet, $item);
|
|
}
|
|
|
|
$purchase->delete();
|
|
|
|
$this->dispatch('refreshDatatable');
|
|
|
|
$this->toast('Belanja berhasil dihapus.');
|
|
|
|
Flux::modals()->close();
|
|
}
|
|
|
|
public function render()
|
|
{
|
|
return view('livewire.studio.manage.purchase.index', [
|
|
'pageTitle' => 'Belanja',
|
|
]);
|
|
}
|
|
}
|