- Added RawMaterialController and RawMaterialVariantController for managing raw materials and their variants. - Introduced RawMaterialRequest and RawMaterialVariantRequest for validation. - Implemented RawMaterialService and RawMaterialVariantService for business logic. - Created hooks for saving drafts of raw materials. - Developed UI components for creating, editing, and listing raw materials and variants.
42 lines
979 B
PHP
42 lines
979 B
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Admin\Master\RawMaterial;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
class RawMaterialVariantRequest extends FormRequest
|
|
{
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public function prepareForValidation(): void
|
|
{
|
|
$price = $this->price;
|
|
if (is_string($price)) {
|
|
$this->request->set('price', (int) str_replace('.', '', $price));
|
|
}
|
|
}
|
|
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'variant' => ['required', 'string', 'max:200'],
|
|
'price' => ['required', 'integer', 'min:0'],
|
|
'stock' => ['required', 'numeric', 'min:0'],
|
|
'photo_key' => ['required', 'string', 'max:500'],
|
|
];
|
|
}
|
|
|
|
public function attributes(): array
|
|
{
|
|
return [
|
|
'variant' => 'Nama Varian',
|
|
'price' => 'Harga',
|
|
'stock' => 'Stok',
|
|
'photo_key' => 'Foto',
|
|
];
|
|
}
|
|
}
|