movemoveapp/laravel-dadata2
Laravel wrapper for the DaData2 API, making it easy to add Russian address, company, and bank data suggestions and validation to your application through a clean, configurable integration.
Install the package via Composer and publish any config if your version requires it:
composer require <vendor>/<package>
php artisan vendor:publish --tag=<package>-config
The first place to look is the Phone value object and any Eloquent cast it provides. A typical first use case is normalizing and validating a phone number stored on a model:
use Vendor\Package\Phone;
$phone = Phone::make('+1 (555) 123-4567');
$phone->formatE164(); // +15551234567
If your app stores a contact field as part of a Phone object, v2.1.4 fixes a type casting error there—start by updating to this patch and verifying that existing records hydrate correctly.
Value object casting in models
Use the package’s cast to convert raw database values into Phone instances automatically:
protected $casts = [
'phone' => PhoneCast::class,
];
This keeps formatting and validation logic out of controllers and models.
Validation and normalization workflow
Combine the package’s validation rule with a form request, then normalize before saving:
public function rules()
{
return [
'phone' => ['required', new PhoneRule()],
];
}
public function prepareForValidation()
{
$this->merge([
'phone' => Phone::make($this->phone)->formatE164(),
]);
}
API resources
Expose both a formatted and raw version of the phone number:
return [
'phone' => $this->phone->formatInternational(),
'phone_e164' => $this->phone->formatE164(),
];
Contact field handling
If you use the contact field on the Phone object, treat it as a first-class attribute. After upgrading to v2.1.4, confirm that mass assignment, casts, and serialization all return the expected type (string vs. int) for your use case.
contact field. The patch fixes a type casting error in the Phone object. If you previously worked around missing or incorrectly cast contact values, remove those workarounds after updating.null or throw depending on configuration. Guard against empty strings before calling Phone::make().Phone object behaves unexpectedly, inspect the raw model attribute ($model->getRawOriginal('phone')) and the cast result separately. The v2.1.4 fix was specifically about type casting on the contact field, so verify both raw and casted representations.contact field type and value round-trips through the cast.How can I help you explore Laravel packages today?