rmarsigli / filament-address
Address form plugin for Filament
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/rmarsigli/filament-address
Requires
- php: ^8.2
- laravel/framework: ^11.0
This package is auto-updated.
Last update: 2025-12-08 06:02:44 UTC
README
This library is a solution for a recurring application in my applications, witch is to use an address solution without streets, but with neighborhoods, cities and states.
Note: it already has a Seeder ready for neighborhoods, cities and states in Brazil.
How to use
First, install the package:
composer require rmarsigli/filament-address
Publish migration and (optionally) language:
php artisan vendor:publish --tags=filament-address-migration
php artisan vendor:publish --tags=filament-address-lang
Add the polymorphic relation to the resource model:
use Rmarsigli\FilamentAddress\Models\Address; public function address(): MorphOne { return $this->morphOne( Address::class, 'address', 'address_type', 'address_id' ); }
Using the form in Filament
Use hasAddress trait in your Filament resource:
use Rmarsigli\FilamentAddress\Traits\HasAddress; ... // Filament classes class MyResource extends Resource { use HasAddress; public static function form(Form $form): Form { $resourceInstance = new self(); return $form ->schema([ Section::make()->schema( $resourceInstance->getAddressFields(), ) ->inlineLabel(), ->hiddenOn('create') ]); } }
The inlineLabel() is totally optional, and hiddenOn('create') method is to ensure that it will be executed when the Resource has an id.
Using this package with Laravel
Without Filament, you can use this package. Import the models and integrate with your controller. Models are:
use Rmarsigli\FilamentAddress\Models\Address; use Rmarsigli\FilamentAddress\Models\AddressCity; use Rmarsigli\FilamentAddress\Models\AddressState; use Rmarsigli\FilamentAddress\Models\AddressCountry;
Check project files for models structure.
Brazilian automatic seeder
Maybe in another countries soon.
use Rmarsigli\FilamentAddress\Seeders\AddressSeeder; class DatabaseSeeder extends Seeder { public function run(): void { $this->call([ AddressSeeder::class, ]); } }