parfum/app/Livewire/Forms/Studio/Stock/StockOpnameForm.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

62 lines
1.3 KiB
PHP

<?php
namespace App\Livewire\Forms\Studio\Stock;
use App\Models\StockOpname;
use App\Models\StockOpnameItem;
use App\Rules\UnsignedInteger;
use Livewire\Form;
class StockOpnameForm extends Form
{
public StockOpname $stockOpname;
public array $outlet_stock = [];
public ?string $note = null;
public function rules(): array
{
return [
'outlet_stock' => 'array',
'outlet_stock.*' => ['nullable', new UnsignedInteger],
'note' => 'nullable',
];
}
public function validationAttributes(): array
{
return [
'outlet_stock' => 'stock outlet',
'outlet_stock.*' => 'stock outlet',
'note' => 'catatan',
];
}
public function setStockOpname(StockOpname $stockOpname): void
{
$stockOpname->load('items');
$this->stockOpname = $stockOpname;
$this->note = $stockOpname->note;
}
public function update(): void
{
$this->validate();
$this->stockOpname->update(['note' => $this->note]);
foreach ($this->outlet_stock as $itemId => $qtyPhysical) {
$item = StockOpnameItem::find($itemId);
if (! $item) {
continue;
}
$item->qty_physical = $qtyPhysical;
$item->save();
}
}
}