Skip to content

Conversation

@roncodes
Copy link
Member

@roncodes roncodes commented Jan 9, 2026

Problem

The internal was incomplete and missing validation for required fields like , , and . This caused two issues:

  1. Silent failures: Driver creation requests would fail without clear error messages
  2. Missing validation: Drivers could be submitted without required fields through the internal API

The controller extracts data from $request->input('driver') but the validation rules didn't properly validate this nested data.

Solution

Updated server/src/Http/Requests/Internal/CreateDriverRequest.php with:

Required Fields (for creation)

  • name - Driver name (required, max 255 chars)
  • email - Email address (required, must be valid email, unique)
  • phone - Phone number (required, unique)

Optional Fields

  • password - Minimum 8 characters
  • drivers_license_number - Driver's license number
  • internal_id - Internal identifier
  • country - 2-letter country code
  • city - City name
  • vehicle - Vehicle assignment
  • status - active/inactive
  • vendor - Vendor assignment
  • job - Order assignment
  • location, latitude, longitude - Location data
  • photo_uuid, avatar_uuid - Photo uploads

Improvements

  • ✅ Custom error messages for better UX
  • ✅ Custom attribute names for clearer validation errors
  • ✅ Email and phone uniqueness validation
  • ✅ Password minimum length enforcement
  • ✅ Proper validation for all driver form fields

Testing

  • Driver creation now requires name, email, and phone
  • Validation errors are clear and user-friendly
  • Email and phone uniqueness is enforced
  • Optional fields validate correctly when provided
  • UpdateDriverRequest inherits these rules automatically

Impact

  • Onboarding flow: Driver creation during onboarding now works correctly with proper validation
  • Internal API: All internal driver creation requests now have proper validation
  • User experience: Clear error messages when validation fails

Related Issues

Fixes driver creation failures in onboarding flow where users could submit empty forms.

- Add required validation for name, email, and phone fields
- Add validation for drivers_license_number and internal_id
- Add validation for photo_uuid and avatar_uuid
- Add validation for location fields (latitude, longitude)
- Add custom error messages for better UX
- Add custom attribute names for clearer validation errors
- Ensure email and phone uniqueness checks
- Add password minimum length validation (8 characters)

This fixes the issue where drivers could be created without
required fields through the internal API, and improves the
validation error messages shown to users.

Resolves issue where onboarding driver creation was failing
silently due to incomplete validation rules.
- Check if user exists before calling methods on it
- Create new user if user_uuid is provided but user doesn't exist
- Prevents 'Call to a member function companies() on null' error
- Fixes driver creation failure when invalid user_uuid is provided

This resolves the error:
Error: Call to a member function companies() on null
in DriverController.php on line 172
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants