SaveProductionOrderDeliveryRequest.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Http\Requests;
  4. use App\Models\Role;
  5. use Illuminate\Database\Query\Builder;
  6. use Illuminate\Foundation\Http\FormRequest;
  7. use Illuminate\Validation\Rule;
  8. class SaveProductionOrderDeliveryRequest extends FormRequest
  9. {
  10. public function authorize(): bool
  11. {
  12. return true;
  13. }
  14. /** @return array<string, mixed> */
  15. public function rules(): array
  16. {
  17. return [
  18. 'delivery_date' => ['required', 'date'],
  19. 'delivery_time' => ['nullable', 'date_format:H:i'],
  20. 'driver_id' => [
  21. 'required',
  22. 'integer',
  23. Rule::exists('users', 'id')->where(
  24. fn (Builder $query): Builder => $query
  25. ->whereIn('role', [Role::DRIVER, Role::BRIGADIER])
  26. ->whereNull('deleted_at'),
  27. ),
  28. ],
  29. 'carrier' => ['nullable', 'string', 'max:255'],
  30. 'request_number' => ['nullable', 'string', 'max:100'],
  31. 'request_date' => ['nullable', 'date'],
  32. 'carrier_note' => ['nullable', 'string', 'max:5000'],
  33. 'contact_position' => ['nullable', 'string', 'max:255'],
  34. 'contact_name' => ['nullable', 'string', 'max:255'],
  35. 'contact_phone' => ['nullable', 'string', 'max:100'],
  36. 'desired_time' => ['nullable', 'date_format:H:i'],
  37. 'access_system' => ['nullable', 'string', 'max:5000'],
  38. 'unloading_place' => ['nullable', 'string', 'max:5000'],
  39. 'advance_notice' => ['nullable', 'string', 'max:5000'],
  40. 'document_signing_method' => ['nullable', 'string', 'max:5000'],
  41. 'has_passports_and_certificates' => ['required', 'boolean'],
  42. 'note' => ['nullable', 'string', 'max:10000'],
  43. 'nav' => ['nullable', 'string', 'max:100'],
  44. ];
  45. }
  46. /** @return array<string, string> */
  47. public function attributes(): array
  48. {
  49. return [
  50. 'delivery_date' => 'дата доставки',
  51. 'delivery_time' => 'время доставки',
  52. 'driver_id' => 'водитель',
  53. 'request_number' => 'номер заявки',
  54. 'request_date' => 'дата заявки',
  55. 'desired_time' => 'желаемое время доставки',
  56. 'has_passports_and_certificates' => 'наличие паспортов и сертификатов',
  57. ];
  58. }
  59. }