[ 'required', 'string', Rule::in(array_column(DeliveryStatus::cases(), 'value')), ], 'changed_by' => [ 'nullable', 'string', Rule::in(['customer', 'restaurant', 'rider', 'admin', 'system', 'api']), ], 'notes' => ['nullable', 'string', 'max:500'], 'latitude' => ['nullable', 'numeric', 'between:-90,90'], 'longitude' => ['nullable', 'numeric', 'between:-180,180'], // For delivery proof 'photo' => ['nullable', 'string'], 'signature' => ['nullable', 'string'], 'recipient_name' => ['nullable', 'string', 'max:100'], // For cancellation 'cancellation_reason' => [ 'nullable', 'required_if:status,cancelled', 'string', 'max:255', ], ]; } /** * Get custom attributes for validator errors. */ public function attributes(): array { return [ 'status' => 'delivery status', 'changed_by' => 'status changed by', 'cancellation_reason' => 'cancellation reason', ]; } /** * Get the error messages for the defined validation rules. */ public function messages(): array { return [ 'status.in' => 'The selected status is invalid.', 'cancellation_reason.required_if' => 'A cancellation reason is required when cancelling a delivery.', ]; } }