feat: Implement product and product category management with dedicated CRUD operations, services, and repositories.
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Product;
|
||||
|
||||
use App\Enums\Product\ProductTypeEnums;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class StoreProductRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'price' => ['required', 'numeric', 'min:0'],
|
||||
'price_sale' => ['nullable', 'numeric', 'min:0'],
|
||||
'description' => ['nullable', 'string'],
|
||||
'status' => ['required', 'integer'], // Value from Status Enum
|
||||
'type_id' => ['required', 'integer'],
|
||||
];
|
||||
|
||||
// Infer product type from type_id (Legacy mapping needs to be consistent with Controller)
|
||||
// Controller map: 1=>Addon, 2=>Domain, 3=>Hosting, 4=>VPS
|
||||
// We can access input 'type_id'
|
||||
$typeId = (int) $this->input('type_id');
|
||||
|
||||
if ($typeId === 4) { // VPS
|
||||
$rules = array_merge($rules, [
|
||||
'cpu' => ['required'],
|
||||
'ram' => ['required'],
|
||||
'disk' => ['required'],
|
||||
'bandwidth' => ['required'],
|
||||
]);
|
||||
}
|
||||
|
||||
return $rules;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user