parfum/app/Livewire/Studio/Manage/StockTransfer/Index.php
Yoga Pangestu dffc9f9e72 feat: add stock transfer management functionality
- Implemented stock transfer creation and management with Livewire components.
- Created StockTransfer and StockTransferItem models with necessary relationships.
- Added migration files for stock_transfers and stock_transfer_items tables.
- Developed traits for handling stock transfer items (add, delete, update).
- Integrated stock transfer logging in StockActivityLogService.
- Updated ViewServiceProvider to include stock transfer permissions and routes.
- Created frontend views for stock transfer form and index with appropriate UI components.
- Added role permissions for stock transfer actions in RolePermissionSeeder.
2026-01-09 21:41:49 +07:00

50 lines
1.5 KiB
PHP

<?php
namespace App\Livewire\Studio\Manage\StockTransfer;
use App\Models\StockTransfer;
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\StockTransfer\WithStockTransferStock;
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('Transfer Stok')]
class Index extends Component
{
use WithAuthorization, WithCloseModal, WithConfirmation, WithRequestNotification, WithStockTransferStock, WithSubscribeNotification, WithToast;
public function delete(StockTransfer $stockTransfer): void
{
$this->canOrAbort('delete stock transfer');
DB::transaction(function () use ($stockTransfer) {
foreach ($stockTransfer->items as $item) {
$this->reverseStockTransferBetweenOutlets($stockTransfer->sourceOutlet, $stockTransfer->destinationOutlet, $item);
}
$stockTransfer->delete();
});
$this->dispatch('refreshDatatable');
$this->toast('Transfer stok berhasil dihapus.');
Flux::modals()->close();
}
public function render(): View
{
return view('livewire.studio.manage.stock-transfer.index', [
'pageTitle' => 'Transfer Stok Antar Outlet',
]);
}
}