Certainly! Here’s an example response that you could post as a solution on the Laracasts forum in response to the Filament Address Pro package announcement. This will give fellow users a quick primer on how to integrate and use Filament Address Pro in a typical Filament resource.
Solution: Integrating Filament Address Pro in your Filament Resource
Awesome work on this package—solving the international address nightmare is no small feat.
If anyone is wondering how to implement this in practice, here’s a quick step-by-step guide:
- Install the Package
First, if you haven't already, follow the installation instructions in the docs. Typically, that’s:
composer require viewflex/filament-address-pro
php artisan migrate
- Add the HasAddresses trait to your model
For example, if you want your User model to have addresses:
use Viewflex\AddressPro\Traits\HasAddresses;
class User extends Model
{
use HasAddresses;
}
- Add the AddressForm to Your Filament Resource
In your Filament resource (e.g., UserResource):
use Viewflex\AddressPro\Filament\AddressForm;
// inside the form() method of your Filament resource/page/panel:
public static function form(Form $form): Form
{
return $form
->schema([
// ...other fields,
AddressForm::make()->relationship('addresses'),
// ...other fields,
]);
}
Note:
The relationship must be namedaddressesunless you’ve customized it.
For polymorphic usage, consult the official documentation.
- Configuring Inputs and Verification
You can configure the input mode (e.g., Google Places autocomplete), verification APIs, and more.
Check the docs for all options, e.g.:
AddressForm::make()
->relationship('addresses')
->inputMode('places') // 'freeform', 'manual'
->verificationService('google'); // 'usps', 'smarty'
- Display Addresses in Tables or Views
To show the verified/standardized address in your tables or detail views, you might use:
TextColumn::make('addresses.formatted_address'),
- More Features
- Bulk verification: Use artisan commands or the admin panel
- Audit logging, import/export, scoring: All via the built-in admin panel
Full Docs:
For all configuration and advanced use cases (bulk verification, API keys, polymorphism), see: https://docs.viewflex.net/filament-address-pro
Demo and Pricing:
See: https://viewflex.net/packages/premium/filament-address-pro
If you run into any specific integration questions, feel free to ask!
Example Code Recap:
// User model
use Viewflex\AddressPro\Traits\HasAddresses;
class User extends Model
{
use HasAddresses;
}
// In your Filament resource's form schema
use Viewflex\AddressPro\Filament\AddressForm;
public static function form(Form $form): Form
{
return $form
->schema([
AddressForm::make()->relationship('addresses'),
]);
}
Hope this helps anyone curious about how to get started! 🎉