Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Dadata2 Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Getting Started

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.

Implementation Patterns

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.

Gotchas and Tips

  • Update to v2.1.4 if you use the 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 and empty values. Casting a null phone number may return null or throw depending on configuration. Guard against empty strings before calling Phone::make().
  • Locale sensitivity. Formatting methods often rely on a default region. Set the region explicitly in config or pass it to the formatter to avoid inconsistent output across environments.
  • Debugging casts. When a 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.
  • Extension points. Most packages in this space allow custom casts, macros, or config-driven validation rules. If you need custom formatting, prefer extending the package’s formatter rather than duplicating logic.
  • Test after upgrading. Even patch releases can change hydration behavior. Add a test that asserts the contact field type and value round-trips through the cast.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
pharaonic/laravel-notification-dependencies
beautinow/translug
dev-brainiac/bot-cloaked
octoberrain/html
octoberrain/extension
octoberrain/exception
octoberrain/contracts
frankyso/ipaymu
3mdikram/worldmoneywords
snowsoft/config
itmosoft/laravel-subscriptions
larva/laravel-ai-qwen
adachsoft/api-version-bundle
cgv/localized-resource
noith/settings
kda/laravel-package
kda/filament-dynamic-navigation
bypersoft/signbox
pairus/product-data
fayne/laravel-filament-cms-core