feat: Implement product and product category management with dedicated CRUD operations, services, and repositories.

This commit is contained in:
pbao9
2026-02-06 11:05:18 +07:00
parent eef04846a8
commit 92151261b3
61 changed files with 2331 additions and 656 deletions
@@ -0,0 +1,41 @@
<?php
namespace App\Http\Requests\Product;
use Illuminate\Foundation\Http\FormRequest;
class UpdateProductRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
// Based on existing controller logic, update rules are similar but allow optional fields if strictly updating parameters
// However, standard update often requires validating presence if they are being updated.
// Controller used specific rules.
// We need to fetch the product to know its type if 'type_id' is not in request (usually it is in hidden field).
// Assuming type_id is present in update form as per Controller logic.
$rules = [
'name' => ['required', 'string', 'max:255'],
'price' => ['required', 'numeric', 'min:0'],
'product_id' => ['required', 'exists:products,id'],
];
$typeId = (int) $this->input('type_id');
if ($typeId === 4) { // VPS
$rules = array_merge($rules, [
'cpu' => ['required'],
'ram' => ['required'],
'disk' => ['required'],
]);
}
return $rules;
}
}