StoreCommonCatalogItemRequest.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Http\Requests;
  4. use App\Models\CommonCatalogItem;
  5. use Illuminate\Foundation\Http\FormRequest;
  6. use Illuminate\Validation\Rule;
  7. class StoreCommonCatalogItemRequest extends FormRequest
  8. {
  9. public function authorize(): bool
  10. {
  11. return true;
  12. }
  13. public function rules(): array
  14. {
  15. $item = $this->route('commonCatalogItem');
  16. return [
  17. 'article' => [
  18. 'required',
  19. 'string',
  20. 'max:100',
  21. Rule::unique('common_catalog_items', 'article')->ignore(
  22. $item instanceof CommonCatalogItem ? $item->getKey() : null,
  23. ),
  24. ],
  25. 'calculator_name' => ['required', 'string'],
  26. 'kind' => ['nullable', 'string', 'max:255'],
  27. 'dimensions' => ['nullable', 'string'],
  28. 'fall_height' => ['nullable', 'numeric', 'min:0'],
  29. 'additional_info' => ['nullable', 'string'],
  30. 'dimension_unit' => ['nullable', 'string', 'max:50'],
  31. 'weight' => ['nullable', 'numeric', 'min:0'],
  32. 'volume' => ['nullable', 'numeric', 'min:0'],
  33. 'places' => ['nullable', 'integer', 'min:0'],
  34. 'composition' => ['nullable', 'string'],
  35. 'age_group' => ['nullable', 'string', 'max:100'],
  36. 'max_users' => ['nullable', 'integer', 'min:0'],
  37. 'unit' => ['nullable', 'string', 'max:50'],
  38. 'series' => ['nullable', 'string', 'max:255'],
  39. 'trademark' => ['nullable', 'string', 'max:255'],
  40. 'note' => ['nullable', 'string'],
  41. ];
  42. }
  43. }