- Add RestockIndex component for displaying and managing restocks. - Create RestockCardRow component for rendering individual restock items. - Implement RestockItemSubRow component for displaying detailed item information. - Define routes for restock management in web.php. - Create RestockTest to cover various scenarios for restock creation, updating, and deletion. - Ensure proper handling of permissions for restock actions. - Add validation for restock data and ensure correct relationships are maintained.
40 lines
1.1 KiB
PHP
40 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Admin\Manage;
|
|
|
|
use App\Enums\ProductStockQuality;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Validation\Rule;
|
|
|
|
class RestockRequest extends FormRequest
|
|
{
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'stock_type' => ['sometimes', 'required', Rule::in(ProductStockQuality::values())],
|
|
'items' => ['required', 'array', 'min:1'],
|
|
'items.*.product_variant_id' => ['required', 'integer', 'exists:product_variants,id'],
|
|
'items.*.quantity' => ['required', 'integer', 'min:1'],
|
|
'notes' => ['nullable', 'string', 'max:100'],
|
|
'photo_key' => ['nullable', 'string', 'max:500'],
|
|
];
|
|
}
|
|
|
|
public function attributes(): array
|
|
{
|
|
return [
|
|
'stock_type' => 'Jenis Stok',
|
|
'items' => 'Item Produk',
|
|
'items.*.product_variant_id' => 'Varian Produk',
|
|
'items.*.quantity' => 'Jumlah',
|
|
'notes' => 'Keterangan',
|
|
'photo_key' => 'Foto',
|
|
];
|
|
}
|
|
}
|