parfum/app/Livewire/Studio/Stock/Purchase/Index.php
Yoga Pangestu 293dd7d1fd refactor: restructure stock management components and update routes
- Removed legacy stock management components including PurchaseForm, RestockForm, StockOpnameForm, and StockTransferForm.
- Updated routes to reflect new structure under 'studio.stock' namespace for better organization.
- Adjusted view files for stock management to align with the new routing and component structure.
- Modified action routes in the ViewServiceProvider to ensure proper access control and navigation.
- Cleaned up related test files to remove references to deleted components.
2026-01-09 21:57:06 +07:00

50 lines
1.3 KiB
PHP

<?php
namespace App\Livewire\Studio\Stock\Purchase;
use App\Models\Purchase;
use App\Traits\Authorization\WithAuthorization;
use App\Traits\Components\WithCloseModal;
use App\Traits\Components\WithConfirmation;
use App\Traits\Components\WithToast;
use App\Traits\Notification\WithSubscribeNotification;
use App\Traits\Purchase\WithUpdateStock;
use App\Traits\Utilities\WithRequestNotification;
use Flux\Flux;
use Illuminate\Contracts\View\View;
use Illuminate\Support\Facades\DB;
use Livewire\Attributes\Title;
use Livewire\Component;
#[Title('Belanja')]
class Index extends Component
{
use WithAuthorization, WithCloseModal, WithConfirmation, WithRequestNotification, WithSubscribeNotification, WithToast, WithUpdateStock;
public function delete(Purchase $purchase): void
{
$this->canOrAbort('delete purchase');
DB::transaction(function () use ($purchase) {
foreach ($purchase->items as $item) {
$this->decreaseWarehouseStock($purchase->warehouse, $item);
}
$purchase->delete();
});
$this->dispatch('refreshDatatable');
$this->toast('Belanja berhasil dihapus.');
Flux::modals()->close();
}
public function render(): View
{
return view('livewire.studio.stock.purchase.index', [
'pageTitle' => 'Belanja',
]);
}
}