bazuka/filament-address
Composer 安装命令:
composer require bazuka/filament-address
包简介
A Filament plugin for Danish address autocomplete
README 文档
README
A Filament v5 plugin that integrates the Danish Adressevælger API into your Filament forms. Provides an autocomplete input field for Danish addresses, backed by a polymorphic Address model.
Requirements
- PHP 8.2+
- Laravel 11.28+
- Filament 5+
Installation
Install via Composer:
composer require bazuka/filament-address
Publish and run the migration:
php artisan vendor:publish --tag=filament-address-migrations php artisan migrate
Optionally publish the config:
php artisan vendor:publish --tag=filament-address-config
Add your API token to .env:
FILAMENT_ADDRESS_API_TOKEN=your-token-here
Obtain a token from adressevaelger.dk or your administrator.
Custom Theme (required)
This plugin uses Tailwind CSS utility classes, so your Filament panel must have a custom theme. If you haven't created one yet:
php artisan make:filament-theme
Follow the output instructions to register the theme in your panel provider, then add the plugin's views as a Tailwind source in the generated theme CSS file (e.g. resources/css/filament/admin/theme.css):
@source '../../../../vendor/bazuka/filament-address/resources/views/**/*';
Then rebuild your assets:
npm run build
Register the plugin in your Filament panel provider:
use Bazuka\FilamentAddress\FilamentAddressPlugin; public function panel(Panel $panel): Panel { return $panel ->plugins([ FilamentAddressPlugin::make(), ]); }
Usage
1. Prepare your model
Add the HasAddresses trait to any Eloquent model that should have addresses:
use Bazuka\FilamentAddress\Concerns\HasAddresses; class Customer extends Model { use HasAddresses; }
This gives the model two relationships:
| Method | Returns | Description |
|---|---|---|
address() |
MorphOne |
The primary (first) address |
addresses() |
MorphMany |
All addresses |
2. Add the form field
Use AddressInput in any Filament form. When the user picks a suggestion, the address is automatically saved via the HasAddresses trait:
use Bazuka\FilamentAddress\Forms\Components\AddressInput; AddressInput::make('address') ->label('Address') ->placeholder('Start typing an address…') ->suggestionCount(8),
The field calls the Adressevælger API directly from the browser as the user types (debounced at 300 ms).
3. Reading the stored address
$customer = Customer::with('address')->find($id); $customer->address->formatted_address; // "Amaliegade 18, 1256 København K" $customer->address->street_name; // "Amaliegade" $customer->address->postal_code; // "1256" $customer->address->city; // "København K"
Available Address Attributes
| Attribute | Type | Description |
|---|---|---|
source_id |
string (UUID) | Adressevælger unique address identifier |
formatted_address |
string | Full formatted address string |
street_name |
string | Street name |
house_number |
string | House number |
floor |
string|null | Floor |
door |
string|null | Door |
postal_code |
string | Postal code |
city |
string | City name |
municipality_code |
string | Municipality code |
longitude |
float|null | Longitude |
latitude |
float|null | Latitude |
access_address_id |
string|null | Associated house number identifier |
label |
string|null | Optional label (e.g. billing, shipping) |
Configuration
// config/filament-address.php return [ 'address_model' => \Bazuka\FilamentAddress\Models\Address::class, 'api_token' => env('FILAMENT_ADDRESS_API_TOKEN', ''), ];
You can swap in your own model as long as it extends Bazuka\FilamentAddress\Models\Address:
'address_model' => \App\Models\Address::class,
AddressService
For programmatic address lookup outside of forms:
use Bazuka\FilamentAddress\Services\AddressService; // Returns up to $count suggestions from the search endpoint $suggestions = AddressService::addressAutocomplete('Amalieg', 5); // Fetches the full address record for a given address ID $adresse = AddressService::addressById('d632f4fc-8190-4462-846d-47391e9a9afe'); // Returns the full address record for the single best text match, or null $match = AddressService::bestAddressMatch('Amaliegade 18, København');
License
MIT — see LICENSE.
bazuka/filament-address 适用场景与选型建议
bazuka/filament-address 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 04 月 28 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「address」 「laravel」 「filament」 「danish-addresses」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 bazuka/filament-address 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 bazuka/filament-address 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 bazuka/filament-address 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Maps in minutes. Powered by the Google Maps API.
Redirects TYPO3 visitors automatic or with a suggestlink to another language and/or root page.
Module adding custom shipping attribute for what3words address
A modern, feature-rich Laravel package for managing addresses with geocoding, validation, caching, and spatial operations. Perfect for e-commerce, CRM systems, and any application requiring robust address management.
This package provides an Address Model, Migration and Factory. It also provides the traits HasBillingAddres and HasPublicAddress
Symfony Postcode bundle
统计信息
- 总下载量: 5
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 29
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-04-28